本文整理汇总了TypeScript中THREE.Object3D类的典型用法代码示例。如果您正苦于以下问题:TypeScript Object3D类的具体用法?TypeScript Object3D怎么用?TypeScript Object3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Object3D类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: require
( { context, require, cache, detached } ) => {
if ( !cache.object3d ) {
const THREE = require ( 'THREE' )
let lights = new THREE.Object3D ()
cache.object3d = lights
let l
// Sky light
l = new THREE.PointLight ( 0xffffff, 1, 0 )
l.position.set ( 0, 20, 0 )
lights.add ( l )
// Sun light
l = new THREE.PointLight ( 0xffffff, 1, 0 )
l.position.set ( 10, 20, 10 )
lights.add ( l )
// Back light
l = new THREE.PointLight ( 0xffffff, 1, 0 )
l.position.set ( -10, -20, -10 )
lights.add ( l )
context.object3d.add ( cache.object3d )
}
const object3d = cache.object3d
if ( detached ) {
if ( object3d.parent ) {
object3d.parent.remove ( object3d )
}
}
return { object3d }
}
示例2: squareFactory
params.map(({ color, width, offsetX, offsetY }) => {
const square = new THREE.Object3D();
square.add(
squareFactory({
color,
width,
offsetX,
offsetY,
})
);
square.visible = false;
squareParticles.add(square);
});
示例3: triangleFactory
params.map(({ color, offsetX, offsetY }, index) => {
var triangle = new THREE.Object3D();
triangle.add(
triangleFactory({
index,
color,
offsetX,
offsetY,
})
);
triangle.add(blackBarsFactory(offsetX, index));
triangle.visible = false;
triangleParticles.add(triangle);
});
示例4: Array
export const triangleParticlesFactory = () => {
const triangleParticles = new THREE.Object3D();
const params = new Array();
for (let n = 1; n <= 5; n++) {
params.push({ color: colors[n - 1], offsetX: (n - 3) * 100, offsetY: 0 });
}
params.map(({ color, offsetX, offsetY }, index) => {
var triangle = new THREE.Object3D();
triangle.add(
triangleFactory({
index,
color,
offsetX,
offsetY,
})
);
triangle.add(blackBarsFactory(offsetX, index));
triangle.visible = false;
triangleParticles.add(triangle);
});
triangleParticles.position.y = 40;
triangleParticles.position.z = 240;
return triangleParticles;
};
示例5: Array
export const squareParticlesFactory = () => {
const params = new Array();
for (let y = -5; y <= 5; y++) {
for (let x = -5; x <= 5; x++) {
params.push({
color: colors[Math.floor(Math.random() * 5)],
width: 100,
offsetX: 120 * x,
offsetY: 120 * y,
});
}
}
const squareParticles = new THREE.Object3D();
params.map(({ color, width, offsetX, offsetY }) => {
const square = new THREE.Object3D();
square.add(
squareFactory({
color,
width,
offsetX,
offsetY,
})
);
square.visible = false;
squareParticles.add(square);
});
return squareParticles;
};
示例6: if
], (instance: Object3D,
{rotation, quaternion, lookAt}: {
rotation?: Euler,
quaternion?: Quaternion,
lookAt?: Vector3,
}) => {
if (lookAt != null) {
if (isNonProduction) {
if (quaternion != null) {
console.warn("An object is being updated with both 'lookAt' and 'quaternion' properties.\n" +
"Only 'lookAt' will be applied.");
} else if (rotation != null) {
console.warn("An object is being updated with both 'lookAt' and 'rotation' properties.\n" +
"Only 'lookAt' will be applied.");
}
}
instance.lookAt(lookAt);
} else if ((quaternion != null)) {
instance.quaternion.copy(quaternion);
} else if ((rotation != null)) {
instance.rotation.copy(rotation);
} else {
// looks like everything is unset
instance.quaternion.set(0, 0, 0, 0);
}
}).withTypes({
示例7:
export const circleSpectrumFactory = () => {
const spectrum = new THREE.Object3D();
const split = 48;
const theta = Math.PI / split;
const ofs = 5;
const width = 1;
for (let i = 0; i < split * 2; i++) {
const rectShape = new THREE.Shape();
rectShape.moveTo(
ofs * Math.cos(theta * i) +
width * 0.5 * Math.cos(theta * i - Math.PI / 2),
ofs * Math.sin(theta * i) +
width * 0.5 * Math.sin(theta * i - Math.PI / 2)
);
rectShape.lineTo(
ofs * Math.cos(theta * i) +
width * 0.5 * Math.cos(theta * i + Math.PI / 2),
ofs * Math.sin(theta * i) +
width * 0.5 * Math.sin(theta * i + Math.PI / 2)
);
rectShape.lineTo(
10 * Math.cos(theta * i) +
width * 0.5 * Math.cos(theta * i + Math.PI / 2),
10 * Math.sin(theta * i) + width * 0.5 * Math.sin(theta * i + Math.PI / 2)
);
rectShape.lineTo(
10 * Math.cos(theta * i) +
width * 0.5 * Math.cos(theta * i - Math.PI / 2),
10 * Math.sin(theta * i) + width * 0.5 * Math.sin(theta * i - Math.PI / 2)
);
const geometry = new THREE.ShapeGeometry(rectShape);
const material = new THREE.MeshBasicMaterial({
color: colors[2],
fog: false,
});
const line = new THREE.Mesh(geometry, material);
spectrum.add(line);
}
spectrum.position.set(0, 0, 30);
spectrum.visible = false;
return spectrum;
};
示例8:
export const blackBarsFactory = (offsetX: number, index: number) => {
const geometry = new THREE.PlaneBufferGeometry(1024, 8, 1, 1);
const material = new THREE.MeshBasicMaterial({
color: 0x212121,
fog: false,
transparent: true,
opacity: 1,
});
const lines = new THREE.Object3D();
const split = 6;
for (let i = 0; i < split; i++) {
const line = new THREE.Mesh(geometry, material);
line.position.set(i * 50 - 112 + offsetX, 0, -400 + index);
line.rotateZ(Math.PI / 3);
lines.add(line);
}
return lines;
};
示例9: 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
}
示例10: 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
}