本文整理汇总了TypeScript中THREE.SphereGeometry.computeVertexNormals方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SphereGeometry.computeVertexNormals方法的具体用法?TypeScript SphereGeometry.computeVertexNormals怎么用?TypeScript SphereGeometry.computeVertexNormals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.SphereGeometry
的用法示例。
在下文中一共展示了SphereGeometry.computeVertexNormals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(position: Vector3, attr: {
color: Color;
texture: Texture;
displayHalo: boolean;
applyDistortion: boolean;
size: number;
}) {
this.size = attr.size;
this.position = position;
var starMaterial: Material;
attr.texture.wrapS = attr.texture.wrapT = RepeatWrapping;
if (attr.applyDistortion) {
this.starUniforms = {
baseTexture: { type: "t", value: attr.texture },
baseSpeed: { type: "f", value: 0.02 },
repeatS: { type: "f", value: 1.0 },
repeatT: { type: "f", value: 1.0 },
noiseTexture: { type: "t", value: noiseTexture },
noiseScale: { type: "f", value: 0.5 },
blendTexture: { type: "t", value: attr.texture },
blendSpeed: { type: "f", value: 0.01 },
blendOffset: { type: "f", value: 0.25 },
bumpTexture: { type: "t", value: noiseTexture },
bumpSpeed: { type: "f", value: 0.15 },
bumpScale: { type: "f", value: 100.0 },
alpha: { type: "f", value: 1.0 },
time: { type: "f", value: 1.0 }
};
starMaterial = new ShaderMaterial({
uniforms: this.starUniforms,
vertexShader: starVertex,
fragmentShader: starFragment
});
} else {
starMaterial = new MeshBasicMaterial({
map: attr.texture
});
}
var shiny = new Mesh(new SphereGeometry(attr.size, 64, 64), starMaterial);
shiny.position.copy(position);
if (attr.displayHalo) {
this.uniform = {
"c": { type: "f", value: 0.5 },
"p": { type: "f", value: 4 },
glowColor: { type: "c", value: attr.color },
viewVector: { type: "v3", value: new Vector3() }
};
var customMaterial = new ShaderMaterial({
uniforms: this.uniform,
vertexShader: vertex,
fragmentShader: fragment,
side: FrontSide,
blending: AdditiveBlending,
transparent: true
});
var ballGeometry = new SphereGeometry(attr.size, 64, 64);
ballGeometry.computeFaceNormals();
ballGeometry.computeVertexNormals();
var halo = new Mesh(ballGeometry, customMaterial);
halo.scale.multiplyScalar(haloScale);
halo.position.copy(position);
this.halo = halo;
}
this.mesh = shiny;
var priorRotationMatrix = new Matrix4();
var axis = new Vector3(
Math.random() - 0.5,
0,
Math.random() - 0.5
);
priorRotationMatrix.makeRotationAxis(axis.normalize(), Math.random());
this.mesh.matrix.multiply(priorRotationMatrix);
this.rotationMatrix = new Matrix4();
this.rotationMatrix.makeRotationAxis(new Vector3(0, 1, 0), Math.random() * 0.02 + 0.01)
this.mesh.rotation.setFromRotationMatrix(this.mesh.matrix);
}