当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Object3D.add方法代码示例

本文整理汇总了TypeScript中THREE.Object3D.add方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Object3D.add方法的具体用法?TypeScript Object3D.add怎么用?TypeScript Object3D.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在THREE.Object3D的用法示例。


在下文中一共展示了Object3D.add方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 }
}
开发者ID:lucidogen,项目名称:lucy-library,代码行数:31,代码来源:three.Lights.ts

示例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);
 });
开发者ID:Leonardo-mbc,项目名称:Sound-Walker,代码行数:13,代码来源:square-particles.ts

示例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);
 });
开发者ID:Leonardo-mbc,项目名称:Sound-Walker,代码行数:14,代码来源:triangle-particles.ts

示例4:

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;
};
开发者ID:Leonardo-mbc,项目名称:Sound-Walker,代码行数:46,代码来源:circle-spectrum.ts

示例5:

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;
};
开发者ID:Leonardo-mbc,项目名称:Sound-Walker,代码行数:20,代码来源:black-bars.ts

示例6: 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
    }
开发者ID:timofeevda,项目名称:seismic-beachballs-demo,代码行数:41,代码来源:threedoublecouplescene.component.ts

示例7: 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
    }
开发者ID:timofeevda,项目名称:seismic-beachballs-demo,代码行数:39,代码来源:projectedtensorscene.component.ts

示例8:

export const speakerConeFactory = () => {
  const speakerCone = new THREE.Object3D();

  const circleGeometry1 = new THREE.CircleGeometry(8.0, 1024);
  const circleMaterial1 = new THREE.MeshBasicMaterial({
    color: colors[2],
    fog: false,
  });
  speakerCone.add(new THREE.Mesh(circleGeometry1, circleMaterial1));

  const circleGeometry2 = new THREE.CircleGeometry(6.5, 1024);
  const circleMaterial2 = new THREE.MeshBasicMaterial({
    color: 0x000000,
    fog: false,
  });
  speakerCone.add(new THREE.Mesh(circleGeometry2, circleMaterial2));

  const circleGeometry3 = new THREE.CircleGeometry(6.0, 1024);
  const circleMaterial3 = new THREE.MeshBasicMaterial({
    color: colors[2],
  });
  speakerCone.add(new THREE.Mesh(circleGeometry3, circleMaterial3));

  const circleGeometry4 = new THREE.CircleGeometry(5.7, 1024);
  const circleMaterial4 = new THREE.MeshBasicMaterial({
    color: 0x001827,
  });
  speakerCone.add(new THREE.Mesh(circleGeometry4, circleMaterial4));

  const circleGeometry5 = new THREE.CircleGeometry(2.3, 1024);
  const circleMaterial5 = new THREE.MeshBasicMaterial({
    color: colors[2],
  });
  speakerCone.add(new THREE.Mesh(circleGeometry5, circleMaterial5));

  const circleGeometry6 = new THREE.CircleGeometry(2.0, 1024);
  const circleMaterial6 = new THREE.MeshBasicMaterial({
    color: 0x000000,
  });
  speakerCone.add(new THREE.Mesh(circleGeometry6, circleMaterial6));

  speakerCone.visible = false;

  return speakerCone;
};
开发者ID:Leonardo-mbc,项目名称:Sound-Walker,代码行数:45,代码来源:speaker-cone.ts

示例9:

 params.map(({ color, r, z }) => {
   const circle = new THREE.Object3D();
   circle.add(circleFactory({ color, r, z }));
   circle.visible = false;
   circleParticles.add(circle);
 });
开发者ID:Leonardo-mbc,项目名称:Sound-Walker,代码行数:6,代码来源:circle-particles.ts


注:本文中的THREE.Object3D.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。