three#StaticDrawUsage JavaScript Examples

The following examples show how to use three#StaticDrawUsage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DebugDrawer.js    From three-fps with MIT License 5 votes vote down vote up
constructor(scene, world, options = {}) {
     this.scene = scene;
     this.world = world;
     this.options = options;
     this.debugDrawMode = options.debugDrawMode || AmmoDebugConstants.DrawWireframe;
     const drawOnTop = this.debugDrawMode & AmmoDebugConstants.DrawOnTop || false;
     const maxBufferSize = options.maxBufferSize || 1000000;
 
     this.geometry = new BufferGeometry()
     const vertices = new Float32Array(maxBufferSize * 3)
     const colors = new Float32Array(maxBufferSize * 3)
 
     /*
     I do not know the difference, just using the first one.
     export const StaticDrawUsage: Usage;
     export const DynamicDrawUsage: Usage;
     export const StreamDrawUsage: Usage;
     export const StaticReadUsage: Usage;
     export const DynamicReadUsage: Usage;
     export const StreamReadUsage: Usage;
     export const StaticCopyUsage: Usage;
     export const DynamicCopyUsage: Usage;
     export const StreamCopyUsage: Usage;
      */
     this.geometry.setAttribute('position', new BufferAttribute(vertices, 3).setUsage(StaticDrawUsage))
     this.geometry.setAttribute('color', new BufferAttribute(colors, 3).setUsage(StaticDrawUsage))
 
     this.index = 0
 
     const material = new LineBasicMaterial({
       vertexColors: true,
       depthTest: !drawOnTop
     });
 
     this.mesh = new LineSegments(this.geometry, material);
     if (drawOnTop) this.mesh.renderOrder = 999;
     this.mesh.frustumCulled = false;
 
     this.enabled = false;
 
     this.debugDrawer = new Ammo.DebugDrawer();
     this.debugDrawer.drawLine = this.drawLine.bind(this);
     this.debugDrawer.drawContactPoint = this.drawContactPoint.bind(this);
     this.debugDrawer.reportErrorWarning = this.reportErrorWarning.bind(this);
     this.debugDrawer.draw3dText = this.draw3dText.bind(this);
     this.debugDrawer.setDebugMode = this.setDebugMode.bind(this);
     this.debugDrawer.getDebugMode = this.getDebugMode.bind(this);
 
     this.world.setDebugDrawer(this.debugDrawer);
   }