本文整理汇总了TypeScript中THREE.Geometry.computeFaceNormals方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Geometry.computeFaceNormals方法的具体用法?TypeScript Geometry.computeFaceNormals怎么用?TypeScript Geometry.computeFaceNormals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Geometry
的用法示例。
在下文中一共展示了Geometry.computeFaceNormals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: buildSceneContainer
buildSceneContainer() {
let container = new three.Object3D()
let geometry = new three.Geometry()
let momenttensor = this.polygonizedMomentTensor.momentTensor
// moment tensor representing only double couple
let sphericalTensor = beachballs.sdr2mt({ strike: momenttensor.strike, dip: momenttensor.dip, rake: momenttensor.slip })
let doubleCouple = {
Mrr: sphericalTensor.Mrr,
Mtt: sphericalTensor.Mtt,
Mpp: sphericalTensor.Mpp,
Mrt: sphericalTensor.Mrt,
Mrp: sphericalTensor.Mrp,
Mtp: sphericalTensor.Mtp,
strike: momenttensor.strike,
dip: momenttensor.dip,
slip: momenttensor.slip
}
let polygons = beachballs.lowerHemisphereEqualAreaNet(doubleCouple).map(polygon =>
({ vertices: polygon.vertices.map(point => point.map(v => v)), compressional: polygon.compressional }))
this.fillGeometry(geometry, polygons)
geometry.computeFaceNormals()
geometry.computeVertexNormals()
let mesh = new three.Mesh(geometry, new three.MeshBasicMaterial({
vertexColors: three.VertexColors,
side: three.DoubleSide,
wireframe: false,
opacity: 1,
visible: true
}))
container.add(mesh)
return container
}
示例2: buildSceneContainer
buildSceneContainer() {
let container = new three.Object3D()
let geometry = new three.Geometry()
let originalPolygons = this.polygonizedMomentTensor.polygons.map(polygon =>
({vertices: polygon.vertices.map(point => point.map(v => v)), compressional: polygon.compressional}))
let polygons = []
switch (this.projection) {
case "equalarea":
polygons = beachballs.rawLowerHemisphereEqualAreaNet(originalPolygons)
break;
case "wulff":
polygons = beachballs.rawLowerHemisphereWulffNet(originalPolygons)
break;
case "orthographic":
polygons = beachballs.rawLowerHemisphereOrthographic(originalPolygons)
break;
default:
polygons = []
}
this.fillGeometry(geometry, polygons)
geometry.computeFaceNormals()
geometry.computeVertexNormals()
let mesh = new three.Mesh(geometry, new three.MeshBasicMaterial({
vertexColors: three.VertexColors,
side: three.DoubleSide,
wireframe: false,
opacity: 1,
visible: true
}))
container.add(mesh)
return container
}
示例3: addBeachball
private addBeachball(container) {
let geometry = new three.Geometry()
let originalPolygons = this.polygonizedMomentTensor.polygons.map(polygon =>
({ vertices: polygon.vertices.map(point => point.map(v => v)), compressional: polygon.compressional }))
let polygons = originalPolygons
let lowerSphere = this.polygonizedMomentTensor.momentTensor.momentTensorView.lowerHemisphere
let upperSphere = this.polygonizedMomentTensor.momentTensor.momentTensorView.upperHemisphere
if (lowerSphere && upperSphere) {
polygons = originalPolygons
} else if (lowerSphere) {
polygons = beachballs.rawLowerHemisphere(originalPolygons)
} else if (upperSphere) {
polygons = beachballs.rawUpperHemisphere(originalPolygons)
}
this.fillGeometry(geometry, polygons)
geometry.computeFaceNormals()
geometry.computeVertexNormals()
let showMesh = this.polygonizedMomentTensor.momentTensor.momentTensorView.showMesh
var beachballMesh = three.SceneUtils.createMultiMaterialObject(geometry, [
new three.MeshLambertMaterial({
vertexColors: three.VertexColors,
side: three.DoubleSide,
wireframe: false,
opacity: 1,
visible: true
}),
new three.MeshBasicMaterial({ color: 0x222222, wireframe: showMesh, visible: showMesh })
])
container.add(beachballMesh)
}
示例4: function
export default function( value ) {
const idx = geoPool.indexOf( value );
if ( idx !== -1 ) {
// 複数のmeshでthreejs geometryインスタンスを共有したい
return geoCorePool[ idx ];
} else {
geoPool.push( value );
let geometry;
if ( value.type === "Buffer" ) {
geometry = new THREE.BufferGeometry;
} else if ( value.type === "Custom" ) {
geometry = new THREE.Geometry;
value.vertices.forEach( function( vec ) {
geometry.vertices.push( new THREE.Vector3( vec[ 0 ], vec[ 1 ], vec[ 2 ] ) );
});
if ( value.faceVertexUvs ) {
value.faceVertexUvs.forEach( function( faceVertexUv, i ) {
geometry.faceVertexUvs[ i ] = geometry.faceVertexUvs[ i ] || [];
faceVertexUv.forEach( function( uv ) {
geometry.faceVertexUvs[ i ].push([
new THREE.Vector2( uv[ 0 ][ 0 ], uv[ 0 ][ 1 ] ),
new THREE.Vector2( uv[ 1 ][ 0 ], uv[ 1 ][ 1 ] ),
new THREE.Vector2( uv[ 2 ][ 0 ], uv[ 2 ][ 1 ] ),
]);
});
});
}
if ( value.faces ) {
value.faces.forEach( function( face ) {
geometry.faces.push( new THREE.Face3(
face[ 0 ],
face[ 1 ],
face[ 2 ],
face[ 3 ] && new THREE.Vector3( face[ 3 ][ 0 ], face[ 3 ][ 1 ], face[ 3 ][ 2 ] ),
face[ 4 ] && new THREE.Color( face[ 4 ] ),
face[ 5 ]
));
});
if ( !value.faces[ 0 ][ 3 ] ) {
geometry.computeFaceNormals();
geometry.computeVertexNormals();
}
}
geometry.computeBoundingBox();
geometry.computeBoundingSphere();
} else {
geometry = new THREE[ value.type + "Geometry" ](
value.value[ 0 ],
value.value[ 1 ],
value.value[ 2 ],
value.value[ 3 ],
value.value[ 4 ],
value.value[ 5 ],
value.value[ 6 ],
value.value[ 7 ] );
}
if ( value.attrs ) {
let tmp = value.attrs;
let length = tmp.position.length / 3;
let index = attrsPool.indexOf( tmp );
if ( index !== -1 ) {
geometry.attributes = attrsCorePool[ index ];
} else {
for ( let key in tmp ) {
if ( key === "needsUpdate" ) {
continue;
}
if ( key === "index" ) {
geometry.setIndex( Array.isArray( tmp[ key ] ) ? new THREE.Uint16Attribute( tmp[ key ], 1 )
: new THREE.BufferAttribute( tmp[ key ], 1 ) );
} else {
geometry.addAttribute( key, Array.isArray( tmp[ key ] ) ?
new THREE.Float32Attribute( tmp[ key ], tmp[ key ].length / length )
: new THREE.BufferAttribute( tmp[ key ], tmp[ key ].length / length ) );
}
}
attrsPool.push( tmp );
attrsCorePool.push( geometry.attributes );
indexAttrsCorePool.push( geometry.getIndex() );
Object.defineProperty( tmp, "needsUpdate", {
get: function () {
return attrsCorePool[ attrsPool.indexOf( this ) ].position.needsUpdate;
},
set: function ( bool ) {
let index = attrsPool.indexOf( this );
for ( let key in this ) {
if ( key === "needsUpdate" ) {
//.........这里部分代码省略.........