@xeokit/xeokit-sdk 2.4.2-beta-27 → 2.4.2-beta-29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/xeokit-sdk.cjs.js +48 -43
- package/dist/xeokit-sdk.es.js +48 -43
- package/dist/xeokit-sdk.es5.js +31 -31
- package/dist/xeokit-sdk.min.cjs.js +3 -3
- package/dist/xeokit-sdk.min.es.js +3 -3
- package/dist/xeokit-sdk.min.es5.js +3 -3
- package/package.json +1 -1
- package/src/viewer/scene/model/dtx/triangles/renderers/TrianglesDataTextureEdgesColorRenderer.js +18 -13
package/dist/xeokit-sdk.es5.js
CHANGED
|
@@ -3354,7 +3354,7 @@ if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._rende
|
|
|
3354
3354
|
* Destroys this Annotation.
|
|
3355
3355
|
*
|
|
3356
3356
|
* You can also call {@link AnnotationsPlugin#destroyAnnotation}.
|
|
3357
|
-
*/},{key:"destroy",value:function destroy(){if(this._marker){if(!this._markerExternal){this._marker.parentNode.removeChild(this._marker);}else{this._marker.removeEventListener("click",this._onMouseClickedExternalMarker);this._marker.removeEventListener("mouseenter",this._onMouseEnterExternalMarker);this._marker.removeEventListener("mouseleave",this._onMouseLeaveExternalMarker);this._marker=null;}}if(this._label){if(!this._labelExternal){this._label.parentNode.removeChild(this._label);}this._label=null;}this.scene.off(this._onTick);_get(_getPrototypeOf(Annotation.prototype),"destroy",this).call(this);}}]);return Annotation;}(Marker);var tempVec3a$C=math.vec3();var tempVec3b$r=math.vec3();var tempVec3c$
|
|
3357
|
+
*/},{key:"destroy",value:function destroy(){if(this._marker){if(!this._markerExternal){this._marker.parentNode.removeChild(this._marker);}else{this._marker.removeEventListener("click",this._onMouseClickedExternalMarker);this._marker.removeEventListener("mouseenter",this._onMouseEnterExternalMarker);this._marker.removeEventListener("mouseleave",this._onMouseLeaveExternalMarker);this._marker=null;}}if(this._label){if(!this._labelExternal){this._label.parentNode.removeChild(this._label);}this._label=null;}this.scene.off(this._onTick);_get(_getPrototypeOf(Annotation.prototype),"destroy",this).call(this);}}]);return Annotation;}(Marker);var tempVec3a$C=math.vec3();var tempVec3b$r=math.vec3();var tempVec3c$n=math.vec3();/**
|
|
3358
3358
|
* {@link Viewer} plugin that creates {@link Annotation}s.
|
|
3359
3359
|
*
|
|
3360
3360
|
* [<img src="https://user-images.githubusercontent.com/83100/58403089-26589280-8062-11e9-8652-aed61a4e8c64.gif">](https://xeokit.github.io/xeokit-sdk/examples/#annotations_clickFlyToPosition)
|
|
@@ -3776,7 +3776,7 @@ if(utils.isArray(labelHTML)){labelHTML=labelHTML.join("");}labelHTML=this._rende
|
|
|
3776
3776
|
* @param {Number[]} [params.up] Optional World-space position for {@link Camera#up}, used when this Annotation is associated with a {@link Camera} position.
|
|
3777
3777
|
* @param {String} [params.projection] Optional projection type for {@link Camera#projection}, used when this Annotation is associated with a {@link Camera} position.
|
|
3778
3778
|
* @returns {Annotation} The new {@link Annotation}.
|
|
3779
|
-
*/,set:function set(surfaceOffset){if(surfaceOffset===undefined||surfaceOffset===null){surfaceOffset=0.3;}this._surfaceOffset=surfaceOffset;}},{key:"createAnnotation",value:function createAnnotation(params){var _this25=this;if(this.viewer.scene.components[params.id]){this.error("Viewer component with this ID already exists: "+params.id);delete params.id;}var worldPos;var entity;params.pickResult=params.pickResult||params.pickRecord;if(params.pickResult){var pickResult=params.pickResult;if(!pickResult.worldPos||!pickResult.worldNormal){this.error("Param 'pickResult' does not have both worldPos and worldNormal");}else{var normalizedWorldNormal=math.normalizeVec3(pickResult.worldNormal,tempVec3a$C);var offsetVec=math.mulVec3Scalar(normalizedWorldNormal,this._surfaceOffset,tempVec3b$r);var offsetWorldPos=math.addVec3(pickResult.worldPos,offsetVec,tempVec3c$
|
|
3779
|
+
*/,set:function set(surfaceOffset){if(surfaceOffset===undefined||surfaceOffset===null){surfaceOffset=0.3;}this._surfaceOffset=surfaceOffset;}},{key:"createAnnotation",value:function createAnnotation(params){var _this25=this;if(this.viewer.scene.components[params.id]){this.error("Viewer component with this ID already exists: "+params.id);delete params.id;}var worldPos;var entity;params.pickResult=params.pickResult||params.pickRecord;if(params.pickResult){var pickResult=params.pickResult;if(!pickResult.worldPos||!pickResult.worldNormal){this.error("Param 'pickResult' does not have both worldPos and worldNormal");}else{var normalizedWorldNormal=math.normalizeVec3(pickResult.worldNormal,tempVec3a$C);var offsetVec=math.mulVec3Scalar(normalizedWorldNormal,this._surfaceOffset,tempVec3b$r);var offsetWorldPos=math.addVec3(pickResult.worldPos,offsetVec,tempVec3c$n);worldPos=offsetWorldPos;entity=pickResult.entity;}}else{worldPos=params.worldPos;entity=params.entity;}var markerElement=null;if(params.markerElementId){markerElement=document.getElementById(params.markerElementId);if(!markerElement){this.error("Can't find DOM element for 'markerElementId' value '"+params.markerElementId+"' - defaulting to internally-generated empty DIV");}}var labelElement=null;if(params.labelElementId){labelElement=document.getElementById(params.labelElementId);if(!labelElement){this.error("Can't find DOM element for 'labelElementId' value '"+params.labelElementId+"' - defaulting to internally-generated empty DIV");}}var annotation=new Annotation(this.viewer.scene,{id:params.id,plugin:this,entity:entity,worldPos:worldPos,container:this._container,markerElement:markerElement,labelElement:labelElement,markerHTML:params.markerHTML||this._markerHTML,labelHTML:params.labelHTML||this._labelHTML,occludable:params.occludable,values:utils.apply(params.values,utils.apply(this._values,{})),markerShown:params.markerShown,labelShown:params.labelShown,eye:params.eye,look:params.look,up:params.up,projection:params.projection,visible:params.visible!==false});this.annotations[annotation.id]=annotation;annotation.on("destroyed",function(){delete _this25.annotations[annotation.id];_this25.fire("annotationDestroyed",annotation.id);});this.fire("annotationCreated",annotation.id);return annotation;}/**
|
|
3780
3780
|
* Destroys an {@link Annotation}.
|
|
3781
3781
|
*
|
|
3782
3782
|
* @param {String} id ID of Annotation to destroy.
|
|
@@ -5936,7 +5936,7 @@ _this37.left=cfg.left;_this37.right=cfg.right;_this37.bottom=cfg.bottom;_this37.
|
|
|
5936
5936
|
* @param {Number[]} worldPos Outputs un-projected 3D World-space coordinates.
|
|
5937
5937
|
*/},{key:"unproject",value:function unproject(canvasPos,screenZ,screenPos,viewPos,worldPos){var canvas=this.scene.canvas.canvas;var halfCanvasWidth=canvas.offsetWidth/2.0;var halfCanvasHeight=canvas.offsetHeight/2.0;screenPos[0]=(canvasPos[0]-halfCanvasWidth)/halfCanvasWidth;screenPos[1]=(canvasPos[1]-halfCanvasHeight)/halfCanvasHeight;screenPos[2]=screenZ;screenPos[3]=1.0;math.mulMat4v4(this.inverseMatrix,screenPos,viewPos);math.mulVec3Scalar(viewPos,1.0/viewPos[3]);viewPos[3]=1.0;viewPos[1]*=-1;math.mulMat4v4(this.camera.inverseViewMatrix,viewPos,worldPos);return worldPos;}/** @private
|
|
5938
5938
|
*
|
|
5939
|
-
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CustomProjection.prototype),"destroy",this).call(this);this._state.destroy();}}]);return CustomProjection;}(Component);var tempVec3$6=math.vec3();var tempVec3b$q=math.vec3();var tempVec3c$
|
|
5939
|
+
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(CustomProjection.prototype),"destroy",this).call(this);this._state.destroy();}}]);return CustomProjection;}(Component);var tempVec3$6=math.vec3();var tempVec3b$q=math.vec3();var tempVec3c$m=math.vec3();var tempVec3d$9=math.vec3();var tempVec3e$2=math.vec3();var tempVec3f$2=math.vec3();var tempVec4a$d=math.vec4();var tempVec4b$c=math.vec4();var tempVec4c$2=math.vec4();var tempMat=math.mat4();var tempMatb=math.mat4();var eyeLookVec=math.vec3();var eyeLookVecNorm=math.vec3();var eyeLookOffset=math.vec3();var offsetEye=math.vec3();/**
|
|
5940
5940
|
* @desc Manages viewing and projection transforms for its {@link Scene}.
|
|
5941
5941
|
*
|
|
5942
5942
|
* * One Camera per {@link Scene}
|
|
@@ -6139,29 +6139,29 @@ var eye;if(this.projection==="ortho"){math.subVec3(this._eye,this._look,eyeLookV
|
|
|
6139
6139
|
* Rotates {@link Camera#eye} about {@link Camera#look}, around the {@link Camera#up} vector
|
|
6140
6140
|
*
|
|
6141
6141
|
* @param {Number} angleInc Angle of rotation in degrees
|
|
6142
|
-
*/},{key:"orbitYaw",value:function orbitYaw(angleInc){var lookEyeVec=math.subVec3(this._eye,this._look,tempVec3$6);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);lookEyeVec=math.transformPoint3(tempMat,lookEyeVec,tempVec3b$q);this.eye=math.addVec3(this._look,lookEyeVec,tempVec3c$
|
|
6142
|
+
*/},{key:"orbitYaw",value:function orbitYaw(angleInc){var lookEyeVec=math.subVec3(this._eye,this._look,tempVec3$6);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);lookEyeVec=math.transformPoint3(tempMat,lookEyeVec,tempVec3b$q);this.eye=math.addVec3(this._look,lookEyeVec,tempVec3c$m);// Set eye position as 'look' plus 'eye' vector
|
|
6143
6143
|
this.up=math.transformPoint3(tempMat,this._up,tempVec3d$9);// Rotate 'up' vector
|
|
6144
6144
|
}/**
|
|
6145
6145
|
* Rotates {@link Camera#eye} about {@link Camera#look} around the right axis (orthogonal to {@link Camera#up} and "look").
|
|
6146
6146
|
*
|
|
6147
6147
|
* @param {Number} angleInc Angle of rotation in degrees
|
|
6148
|
-
*/},{key:"orbitPitch",value:function orbitPitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var eye2=math.subVec3(this._eye,this._look,tempVec3$6);var left=math.cross3Vec3(math.normalizeVec3(eye2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$
|
|
6148
|
+
*/},{key:"orbitPitch",value:function orbitPitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var eye2=math.subVec3(this._eye,this._look,tempVec3$6);var left=math.cross3Vec3(math.normalizeVec3(eye2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$m));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);eye2=math.transformPoint3(tempMat,eye2,tempVec3d$9);this.up=math.transformPoint3(tempMat,this._up,tempVec3e$2);this.eye=math.addVec3(eye2,this._look,tempVec3f$2);}/**
|
|
6149
6149
|
* Rotates {@link Camera#look} about {@link Camera#eye}, around the {@link Camera#up} vector.
|
|
6150
6150
|
*
|
|
6151
6151
|
* @param {Number} angleInc Angle of rotation in degrees
|
|
6152
|
-
*/},{key:"yaw",value:function yaw(angleInc){var look2=math.subVec3(this._look,this._eye,tempVec3$6);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);look2=math.transformPoint3(tempMat,look2,tempVec3b$q);this.look=math.addVec3(look2,this._eye,tempVec3c$
|
|
6152
|
+
*/},{key:"yaw",value:function yaw(angleInc){var look2=math.subVec3(this._look,this._eye,tempVec3$6);math.rotationMat4v(angleInc*0.0174532925,this._gimbalLock?this._worldUp:this._up,tempMat);look2=math.transformPoint3(tempMat,look2,tempVec3b$q);this.look=math.addVec3(look2,this._eye,tempVec3c$m);if(this._gimbalLock){this.up=math.transformPoint3(tempMat,this._up,tempVec3d$9);}}/**
|
|
6153
6153
|
* Rotates {@link Camera#look} about {@link Camera#eye}, around the right axis (orthogonal to {@link Camera#up} and "look").
|
|
6154
6154
|
|
|
6155
6155
|
* @param {Number} angleInc Angle of rotation in degrees
|
|
6156
|
-
*/},{key:"pitch",value:function pitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var look2=math.subVec3(this._look,this._eye,tempVec3$6);var left=math.cross3Vec3(math.normalizeVec3(look2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$
|
|
6156
|
+
*/},{key:"pitch",value:function pitch(angleInc){if(this._constrainPitch){angleInc=math.dotVec3(this._up,this._worldUp)/math.DEGTORAD;if(angleInc<1){return;}}var look2=math.subVec3(this._look,this._eye,tempVec3$6);var left=math.cross3Vec3(math.normalizeVec3(look2,tempVec3b$q),math.normalizeVec3(this._up,tempVec3c$m));math.rotationMat4v(angleInc*0.0174532925,left,tempMat);this.up=math.transformPoint3(tempMat,this._up,tempVec3f$2);look2=math.transformPoint3(tempMat,look2,tempVec3d$9);this.look=math.addVec3(look2,this._eye,tempVec3e$2);}/**
|
|
6157
6157
|
* Pans the Camera along its local X, Y and Z axis.
|
|
6158
6158
|
*
|
|
6159
6159
|
* @param pan The pan vector
|
|
6160
|
-
*/},{key:"pan",value:function pan(_pan){var eye2=math.subVec3(this._eye,this._look,tempVec3$6);var vec=[0,0,0];var v;if(_pan[0]!==0){var left=math.cross3Vec3(math.normalizeVec3(eye2,[]),math.normalizeVec3(this._up,tempVec3b$q));v=math.mulVec3Scalar(left,_pan[0]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[1]!==0){v=math.mulVec3Scalar(math.normalizeVec3(this._up,tempVec3c$
|
|
6160
|
+
*/},{key:"pan",value:function pan(_pan){var eye2=math.subVec3(this._eye,this._look,tempVec3$6);var vec=[0,0,0];var v;if(_pan[0]!==0){var left=math.cross3Vec3(math.normalizeVec3(eye2,[]),math.normalizeVec3(this._up,tempVec3b$q));v=math.mulVec3Scalar(left,_pan[0]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[1]!==0){v=math.mulVec3Scalar(math.normalizeVec3(this._up,tempVec3c$m),_pan[1]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}if(_pan[2]!==0){v=math.mulVec3Scalar(math.normalizeVec3(eye2,tempVec3d$9),_pan[2]);vec[0]+=v[0];vec[1]+=v[1];vec[2]+=v[2];}this.eye=math.addVec3(this._eye,vec,tempVec3e$2);this.look=math.addVec3(this._look,vec,tempVec3f$2);}/**
|
|
6161
6161
|
* Increments/decrements the Camera's zoom factor, which is the distance between {@link Camera#eye} and {@link Camera#look}.
|
|
6162
6162
|
*
|
|
6163
6163
|
* @param {Number} delta Zoom factor increment.
|
|
6164
|
-
*/},{key:"zoom",value:function zoom(delta){var vec=math.subVec3(this._eye,this._look,tempVec3$6);var lenLook=Math.abs(math.lenVec3(vec,tempVec3b$q));var newLenLook=Math.abs(lenLook+delta);if(newLenLook<0.5){return;}var dir=math.normalizeVec3(vec,tempVec3c$
|
|
6164
|
+
*/},{key:"zoom",value:function zoom(delta){var vec=math.subVec3(this._eye,this._look,tempVec3$6);var lenLook=Math.abs(math.lenVec3(vec,tempVec3b$q));var newLenLook=Math.abs(lenLook+delta);if(newLenLook<0.5){return;}var dir=math.normalizeVec3(vec,tempVec3c$m);this.eye=math.addVec3(this._look,math.mulVec3Scalar(dir,newLenLook),tempVec3d$9);}/**
|
|
6165
6165
|
* Sets the position of the Camera's eye.
|
|
6166
6166
|
*
|
|
6167
6167
|
* Default value is ````[0,0,10]````.
|
|
@@ -13874,7 +13874,7 @@ var positions=K3D.edit.unwrap(m.i_verts,m.c_verts,3);var normals=K3D.edit.unwrap
|
|
|
13874
13874
|
* Destroys this ````LineSet````.
|
|
13875
13875
|
*
|
|
13876
13876
|
* Removes the ```LineSet```` from {@link Scene#lineSets}; causes Scene to fire a "lineSetDestroyed" event.
|
|
13877
|
-
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(LineSet.prototype),"destroy",this).call(this);this.scene._lineSetDestroyed(this);}}]);return LineSet;}(Component);var tempVec3$5=math.vec3();var tempVec3a$u=math.vec3();var tempVec3b$p=math.vec3();var tempVec3c$
|
|
13877
|
+
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(LineSet.prototype),"destroy",this).call(this);this.scene._lineSetDestroyed(this);}}]);return LineSet;}(Component);var tempVec3$5=math.vec3();var tempVec3a$u=math.vec3();var tempVec3b$p=math.vec3();var tempVec3c$l=math.vec3();/**
|
|
13878
13878
|
* {@link Viewer} plugin that saves and loads BCF viewpoints as JSON objects.
|
|
13879
13879
|
*
|
|
13880
13880
|
* [<img src="http://xeokit.github.io/xeokit-sdk/assets/images/BCFViewpointsPlugin.png">](/examples/#BCF_SaveViewpoint)
|
|
@@ -14249,7 +14249,7 @@ alpha=0.1;}else{alpha=scene.xrayMaterial.fillAlpha;}}alpha=Math.round(alpha*255)
|
|
|
14249
14249
|
* then this method will apply the updates to objects within those composites.
|
|
14250
14250
|
*/},{key:"setViewpoint",value:function setViewpoint(bcfViewpoint){var _this69=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};if(!bcfViewpoint){return;}var viewer=this.viewer;var scene=viewer.scene;var camera=scene.camera;var rayCast=options.rayCast!==false;var immediate=options.immediate!==false;var reset=options.reset!==false;var realWorldOffset=scene.realWorldOffset;var reverseClippingPlanes=options.reverseClippingPlanes===true;scene.clearSectionPlanes();if(bcfViewpoint.clipping_planes&&bcfViewpoint.clipping_planes.length>0){bcfViewpoint.clipping_planes.forEach(function(e){var pos=xyzObjectToArray(e.location,tempVec3$5);var dir=xyzObjectToArray(e.direction,tempVec3$5);if(reverseClippingPlanes){math.negateVec3(dir);}math.subVec3(pos,realWorldOffset);if(camera.yUp){pos=ZToY(pos);dir=ZToY(dir);}new SectionPlane(scene,{pos:pos,dir:dir});});}scene.clearLines();if(bcfViewpoint.lines&&bcfViewpoint.lines.length>0){var positions=[];var indices=[];var _i157=0;bcfViewpoint.lines.forEach(function(e){if(!e.start_point){return;}if(!e.end_point){return;}positions.push(e.start_point.x);positions.push(e.start_point.y);positions.push(e.start_point.z);positions.push(e.end_point.x);positions.push(e.end_point.y);positions.push(e.end_point.z);indices.push(_i157++);indices.push(_i157++);});new LineSet(scene,{positions:positions,indices:indices,clippable:false,collidable:true});}scene.clearBitmaps();if(bcfViewpoint.bitmaps&&bcfViewpoint.bitmaps.length>0){bcfViewpoint.bitmaps.forEach(function(e){var bitmap_type=e.bitmap_type||"jpg";// "jpg" | "png"
|
|
14251
14251
|
var bitmap_data=e.bitmap_data;// base64
|
|
14252
|
-
var location=xyzObjectToArray(e.location,tempVec3a$u);var normal=xyzObjectToArray(e.normal,tempVec3b$p);var up=xyzObjectToArray(e.up,tempVec3c$
|
|
14252
|
+
var location=xyzObjectToArray(e.location,tempVec3a$u);var normal=xyzObjectToArray(e.normal,tempVec3b$p);var up=xyzObjectToArray(e.up,tempVec3c$l);var height=e.height||1;if(!bitmap_type){return;}if(!bitmap_data){return;}if(!location){return;}if(!normal){return;}if(!up){return;}if(camera.yUp){location=ZToY(location);normal=ZToY(normal);up=ZToY(up);}new Bitmap(scene,{src:bitmap_data,type:bitmap_type,pos:location,normal:normal,up:up,clippable:false,collidable:true,height:height});});}if(reset){scene.setObjectsXRayed(scene.xrayedObjectIds,false);scene.setObjectsHighlighted(scene.highlightedObjectIds,false);scene.setObjectsSelected(scene.selectedObjectIds,false);}if(bcfViewpoint.components){if(bcfViewpoint.components.visibility){if(!bcfViewpoint.components.visibility.default_visibility){scene.setObjectsVisible(scene.objectIds,false);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.visible=true;});});}}else{scene.setObjectsVisible(scene.objectIds,true);if(bcfViewpoint.components.visibility.exceptions){bcfViewpoint.components.visibility.exceptions.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.visible=false;});});}}var view_setup_hints=bcfViewpoint.components.visibility.view_setup_hints;if(view_setup_hints){if(view_setup_hints.spaces_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcSpace"),false);}if(view_setup_hints.openings_visible===false){scene.setObjectsVisible(viewer.metaScene.getObjectIDsByType("IfcOpening"),false);}if(view_setup_hints.space_boundaries_visible!==undefined);}}if(bcfViewpoint.components.selection){scene.setObjectsSelected(scene.selectedObjectIds,false);bcfViewpoint.components.selection.forEach(function(component){return _this69._withBCFComponent(options,component,function(entity){return entity.selected=true;});});}if(bcfViewpoint.components.coloring){bcfViewpoint.components.coloring.forEach(function(coloring){var color=coloring.color;var alpha=0;var alphaDefined=false;if(color.length===8){alpha=parseInt(color.substring(0,2),16)/256;if(alpha<=1.0&&alpha>=0.95){alpha=1.0;}color=color.substring(2);alphaDefined=true;}var colorize=[parseInt(color.substring(0,2),16)/256,parseInt(color.substring(2,4),16)/256,parseInt(color.substring(4,6),16)/256];coloring.components.map(function(component){return _this69._withBCFComponent(options,component,function(entity){entity.colorize=colorize;if(alphaDefined){if(alpha===0&&_this69.xrayAsZeroAlpha){var savedFromXeokit=component.originating_system===_this69.originatingSystem;if(savedFromXeokit){entity.xrayed=true;}else{entity.opacity=alpha;}}else{entity.opacity=alpha;}}});});});}}if(bcfViewpoint.perspective_camera||bcfViewpoint.orthogonal_camera){var eye;var look;var up;var projection;if(bcfViewpoint.perspective_camera){eye=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.perspective_camera.camera_up_vector,tempVec3$5);camera.perspective.fov=bcfViewpoint.perspective_camera.field_of_view;projection="perspective";}else{eye=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_view_point,tempVec3$5);look=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_direction,tempVec3$5);up=xyzObjectToArray(bcfViewpoint.orthogonal_camera.camera_up_vector,tempVec3$5);camera.ortho.scale=bcfViewpoint.orthogonal_camera.view_to_world_scale;projection="ortho";}math.subVec3(eye,realWorldOffset);if(camera.yUp){eye=ZToY(eye);look=ZToY(look);up=ZToY(up);}if(rayCast){var hit=scene.pick({pickSurface:true,// <<------ This causes picking to find the intersection point on the entity
|
|
14253
14253
|
origin:eye,direction:look});look=hit?hit.worldPos:math.addVec3(eye,look,tempVec3$5);}else{look=math.addVec3(eye,look,tempVec3$5);}if(immediate){camera.eye=eye;camera.look=look;camera.up=up;camera.projection=projection;}else{viewer.cameraFlight.flyTo({eye:eye,look:look,up:up,duration:options.duration,projection:projection});}}}},{key:"_withBCFComponent",value:function _withBCFComponent(options,component,callback){var viewer=this.viewer;var scene=viewer.scene;if(component.authoring_tool_id&&component.originating_system===this.originatingSystem){var id=component.authoring_tool_id;var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var metaObject=viewer.metaScene.metaObjects[id];if(metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);return;}}}if(component.ifc_guid){var originalSystemId=component.ifc_guid;var _entity=scene.objects[originalSystemId];if(_entity){callback(_entity);return;}if(options.updateCompositeObjects){var _metaObject=viewer.metaScene.metaObjects[originalSystemId];if(_metaObject){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(originalSystemId),callback);return;}}Object.keys(scene.models).forEach(function(modelId){var id=math.globalizeObjectId(modelId,originalSystemId);var entity=scene.objects[id];if(entity){callback(entity);return;}if(options.updateCompositeObjects){var _metaObject2=viewer.metaScene.metaObjects[id];if(_metaObject2){scene.withObjects(viewer.metaScene.getObjectIDsInSubtree(id),callback);}}});}}/**
|
|
14254
14254
|
* Destroys this BCFViewpointsPlugin.
|
|
14255
14255
|
*/},{key:"destroy",value:function destroy(){_get(_getPrototypeOf(BCFViewpointsPlugin.prototype),"destroy",this).call(this);}}]);return BCFViewpointsPlugin;}(Plugin);function xyzArrayToObject(arr){return{"x":arr[0],"y":arr[1],"z":arr[2]};}function xyzObjectToArray(xyz,arry){arry=new Float64Array(3);arry[0]=xyz.x;arry[1]=xyz.y;arry[2]=xyz.z;return arry;}function YToZ(vec){return new Float64Array([vec[0],-vec[2],vec[1]]);}function ZToY(vec){return new Float64Array([vec[0],vec[2],-vec[1]]);}function colorizeToRGB(color){var rgb="";rgb+=Math.round(color[0]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[1]*255).toString(16).padStart(2,"0");rgb+=Math.round(color[2]*255).toString(16).padStart(2,"0");return rgb;}var distVec3=math.vec3();var lengthWire=function lengthWire(x1,y1,x2,y2){var a=x1-x2;var b=y1-y2;return Math.sqrt(a*a+b*b);};/**
|
|
@@ -17256,7 +17256,7 @@ NOT_RENDERED:0,// Normal rendering - mutually exclusive modes
|
|
|
17256
17256
|
COLOR_OPAQUE:1,COLOR_TRANSPARENT:2,// Emphasis silhouette rendering - mutually exclusive modes
|
|
17257
17257
|
SILHOUETTE_HIGHLIGHTED:3,SILHOUETTE_SELECTED:4,SILHOUETTE_XRAYED:5,// Edges rendering - mutually exclusive modes
|
|
17258
17258
|
EDGES_COLOR_OPAQUE:6,EDGES_COLOR_TRANSPARENT:7,EDGES_HIGHLIGHTED:8,EDGES_SELECTED:9,EDGES_XRAYED:10,// Picking
|
|
17259
|
-
PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=new Float32Array([0,0,0,1]);var tempVec4=math.vec4();var tempVec3a$s=math.vec3();var tempVec3c$
|
|
17259
|
+
PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=new Float32Array([0,0,0,1]);var tempVec4=math.vec4();var tempVec3a$s=math.vec3();var tempVec3c$k=math.vec3();var tempMat4a$h=math.mat4();/**
|
|
17260
17260
|
* @private
|
|
17261
17261
|
*/var VBOSceneModelRenderer=/*#__PURE__*/function(){function VBOSceneModelRenderer(scene){var withSAO=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var _ref8=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref8$instancing=_ref8.instancing,instancing=_ref8$instancing===void 0?false:_ref8$instancing,_ref8$edges=_ref8.edges,edges=_ref8$edges===void 0?false:_ref8$edges;_classCallCheck(this,VBOSceneModelRenderer);this._scene=scene;this._withSAO=withSAO;this._instancing=instancing;this._edges=edges;this._hash=this._getHash();/**
|
|
17262
17262
|
* Matrices Uniform Block Buffer
|
|
@@ -17276,7 +17276,7 @@ PICK:11};var defaultColor$2=new Float32Array([1,1,1,1]);var edgesDefaultColor=ne
|
|
|
17276
17276
|
* @returns { string }
|
|
17277
17277
|
*/_createClass(VBOSceneModelRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){return[""];}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){return[""];}},{key:"_addMatricesUniformBlockLines",value:function _addMatricesUniformBlockLines(src){var normals=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;src.push("uniform Matrices {");src.push(" mat4 worldMatrix;");src.push(" mat4 viewMatrix;");src.push(" mat4 projMatrix;");src.push(" mat4 positionsDecodeMatrix;");if(normals){src.push(" mat4 worldNormalMatrix;");src.push(" mat4 viewNormalMatrix;");}src.push("};");return src;}},{key:"_addRemapClipPosLines",value:function _addRemapClipPosLines(src){var viewportSize=arguments.length>1&&arguments[1]!==undefined?arguments[1]:1;src.push("uniform vec2 drawingBufferSize;");src.push("uniform vec2 pickClipPos;");src.push("vec4 remapClipPos(vec4 clipPos) {");src.push(" clipPos.xy /= clipPos.w;");if(viewportSize===1){src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * drawingBufferSize;");}else{src.push(" clipPos.xy = (clipPos.xy - pickClipPos) * (drawingBufferSize / float(".concat(viewportSize,"));"));}src.push(" clipPos.xy *= clipPos.w;");src.push(" return clipPos;");src.push("}");return src;}},{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"setSectionPlanesStateUniforms",value:function setSectionPlanesStateUniforms(layer){var scene=this._scene;var gl=scene.canvas.gl;var model=layer.model,layerIndex=layer.layerIndex;var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];var _origin6=layer._state.origin;if(_origin6){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,_origin6,tempVec3a$s);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uColor=program.getLocation("color");if(!this._uColor){// some shader may have color as attribute, in this case the uniform must be renamed silhouetteColor
|
|
17278
17278
|
this._uColor=program.getLocation("silhouetteColor");}this._uUVDecodeMatrix=program.getLocation("uvDecodeMatrix");this._uPickInvisible=program.getLocation("pickInvisible");this._uGammaFactor=program.getLocation("gammaFactor");gl.uniformBlockBinding(program.handle,gl.getUniformBlockIndex(program.handle,"Matrices"),this._matricesUniformBlockBufferBindingPoint);this._uShadowViewMatrix=program.getLocation("shadowViewMatrix");this._uShadowProjMatrix=program.getLocation("shadowProjMatrix");if(scene.logarithmicDepthBufferEnabled){this._uZFar=program.getLocation("zFar");}this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];// TODO add a gard to prevent light params if not affected by light ?
|
|
17279
|
-
var lights=lightsState.lights;var light;for(var _i170=0,len=lights.length;_i170<len;_i170++){light=lights[_i170];switch(light.type){case"dir":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=null;this._uLightDir[_i170]=program.getLocation("lightDir"+_i170);break;case"point":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=program.getLocation("lightPos"+_i170);this._uLightDir[_i170]=null;this._uLightAttenuation[_i170]=program.getLocation("lightAttenuation"+_i170);break;case"spot":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=program.getLocation("lightPos"+_i170);this._uLightDir[_i170]=program.getLocation("lightDir"+_i170);this._uLightAttenuation[_i170]=program.getLocation("lightAttenuation"+_i170);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i171=0,_len20=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i171<_len20;_i171++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i171),pos:program.getLocation("sectionPlanePos"+_i171),dir:program.getLocation("sectionPlaneDir"+_i171)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aNormal=program.getAttribute("normal");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aMetallicRoughness=program.getAttribute("metallicRoughness");this._aFlags=program.getAttribute("flags");this._aPickColor=program.getAttribute("pickColor");this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");this._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uColorMap="uColorMap";this._uMetallicRoughMap="uMetallicRoughMap";this._uEmissiveMap="uEmissiveMap";this._uNormalMap="uNormalMap";this._uAOMap="uAOMap";if(this._instancing){this._aModelMatrix=program.getAttribute("modelMatrix");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");this._aModelNormalMatrixCol0=program.getAttribute("modelNormalMatrixCol0");this._aModelNormalMatrixCol1=program.getAttribute("modelNormalMatrixCol1");this._aModelNormalMatrixCol2=program.getAttribute("modelNormalMatrixCol2");}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}if(scene.pointsMaterial._state.filterIntensity){this._uIntensityRange=program.getLocation("intensityRange");}this._uPointSize=program.getLocation("pointSize");this._uNearPlaneHeight=program.getLocation("nearPlaneHeight");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lightsState=scene._lightsState;var lights=lightsState.lights;program.bind();frameCtx.textureUnit=0;if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,lightsState.getAmbientColorAndIntensity());}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}for(var _i172=0,len=lights.length;_i172<len;_i172++){var light=lights[_i172];if(this._uLightColor[_i172]){gl.uniform4f(this._uLightColor[_i172],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i172]){gl.uniform3fv(this._uLightPos[_i172],light.pos);if(this._uLightAttenuation[_i172]){gl.uniform1f(this._uLightAttenuation[_i172],light.attenuation);}}if(this._uLightDir[_i172]){gl.uniform3fv(this._uLightDir[_i172],light.dir);}}}},{key:"_makeVAO",value:function _makeVAO(state){var gl=this._scene.canvas.gl;var vao=gl.createVertexArray();gl.bindVertexArray(vao);if(this._instancing){this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);if(this._aModelNormalMatrixCol0){this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location,1);}if(this._aModelNormalMatrixCol1){this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location,1);}if(this._aModelNormalMatrixCol2){this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location,1);}}this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(state.uvBuf);}if(this._aNormal){this._aNormal.bindArrayBuffer(state.normalsBuf);}if(this._aMetallicRoughness){this._aMetallicRoughness.bindArrayBuffer(state.metallicRoughnessBuf);if(this._instancing){gl.vertexAttribDivisor(this._aMetallicRoughness.location,1);}}if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf);if(this._instancing&&state.colorsBuf){gl.vertexAttribDivisor(this._aColor.location,1);}}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aFlags.location,1);}}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aOffset.location,1);}}if(this._aPickColor){this._aPickColor.bindArrayBuffer(state.pickColorsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aPickColor.location,1);}}if(this._instancing){if(this._edges){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}else{if(this._edges){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}return vao;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){var _ref9=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref9$colorUniform=_ref9.colorUniform,colorUniform=_ref9$colorUniform===void 0?false:_ref9$colorUniform,_ref9$incrementDrawSt=_ref9.incrementDrawState,incrementDrawState=_ref9$incrementDrawSt===void 0?false:_ref9$incrementDrawSt;var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var scene=this._scene;var gl=scene.canvas.gl;var state=layer._state,model=layer.model;var textureSet=state.textureSet,origin=state.origin,positionsDecodeMatrix=state.positionsDecodeMatrix;var lightsState=scene._lightsState;var pointsMaterial=scene.pointsMaterial;var camera=model.scene.camera;var viewNormalMatrix=camera.viewNormalMatrix,project=camera.project;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate,worldNormalMatrix=model.worldNormalMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(this._vaoCache.has(layer)){gl.bindVertexArray(this._vaoCache.get(layer));}else{this._vaoCache.set(layer,this._makeVAO(state));}var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$s;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$
|
|
17279
|
+
var lights=lightsState.lights;var light;for(var _i170=0,len=lights.length;_i170<len;_i170++){light=lights[_i170];switch(light.type){case"dir":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=null;this._uLightDir[_i170]=program.getLocation("lightDir"+_i170);break;case"point":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=program.getLocation("lightPos"+_i170);this._uLightDir[_i170]=null;this._uLightAttenuation[_i170]=program.getLocation("lightAttenuation"+_i170);break;case"spot":this._uLightColor[_i170]=program.getLocation("lightColor"+_i170);this._uLightPos[_i170]=program.getLocation("lightPos"+_i170);this._uLightDir[_i170]=program.getLocation("lightDir"+_i170);this._uLightAttenuation[_i170]=program.getLocation("lightAttenuation"+_i170);break;}}if(lightsState.reflectionMaps.length>0){this._uReflectionMap="reflectionMap";}if(lightsState.lightMaps.length>0){this._uLightMap="lightMap";}this._uSectionPlanes=[];for(var _i171=0,_len20=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i171<_len20;_i171++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i171),pos:program.getLocation("sectionPlanePos"+_i171),dir:program.getLocation("sectionPlaneDir"+_i171)});}this._aPosition=program.getAttribute("position");this._aOffset=program.getAttribute("offset");this._aNormal=program.getAttribute("normal");this._aUV=program.getAttribute("uv");this._aColor=program.getAttribute("color");this._aMetallicRoughness=program.getAttribute("metallicRoughness");this._aFlags=program.getAttribute("flags");this._aPickColor=program.getAttribute("pickColor");this._uPickZNear=program.getLocation("pickZNear");this._uPickZFar=program.getLocation("pickZFar");this._uPickClipPos=program.getLocation("pickClipPos");this._uDrawingBufferSize=program.getLocation("drawingBufferSize");this._uColorMap="uColorMap";this._uMetallicRoughMap="uMetallicRoughMap";this._uEmissiveMap="uEmissiveMap";this._uNormalMap="uNormalMap";this._uAOMap="uAOMap";if(this._instancing){this._aModelMatrix=program.getAttribute("modelMatrix");this._aModelMatrixCol0=program.getAttribute("modelMatrixCol0");this._aModelMatrixCol1=program.getAttribute("modelMatrixCol1");this._aModelMatrixCol2=program.getAttribute("modelMatrixCol2");this._aModelNormalMatrixCol0=program.getAttribute("modelNormalMatrixCol0");this._aModelNormalMatrixCol1=program.getAttribute("modelNormalMatrixCol1");this._aModelNormalMatrixCol2=program.getAttribute("modelNormalMatrixCol2");}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}if(scene.pointsMaterial._state.filterIntensity){this._uIntensityRange=program.getLocation("intensityRange");}this._uPointSize=program.getLocation("pointSize");this._uNearPlaneHeight=program.getLocation("nearPlaneHeight");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lightsState=scene._lightsState;var lights=lightsState.lights;program.bind();frameCtx.textureUnit=0;if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,lightsState.getAmbientColorAndIntensity());}if(this._uGammaFactor){gl.uniform1f(this._uGammaFactor,scene.gammaFactor);}for(var _i172=0,len=lights.length;_i172<len;_i172++){var light=lights[_i172];if(this._uLightColor[_i172]){gl.uniform4f(this._uLightColor[_i172],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i172]){gl.uniform3fv(this._uLightPos[_i172],light.pos);if(this._uLightAttenuation[_i172]){gl.uniform1f(this._uLightAttenuation[_i172],light.attenuation);}}if(this._uLightDir[_i172]){gl.uniform3fv(this._uLightDir[_i172],light.dir);}}}},{key:"_makeVAO",value:function _makeVAO(state){var gl=this._scene.canvas.gl;var vao=gl.createVertexArray();gl.bindVertexArray(vao);if(this._instancing){this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);if(this._aModelNormalMatrixCol0){this._aModelNormalMatrixCol0.bindArrayBuffer(state.modelNormalMatrixCol0Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol0.location,1);}if(this._aModelNormalMatrixCol1){this._aModelNormalMatrixCol1.bindArrayBuffer(state.modelNormalMatrixCol1Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol1.location,1);}if(this._aModelNormalMatrixCol2){this._aModelNormalMatrixCol2.bindArrayBuffer(state.modelNormalMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelNormalMatrixCol2.location,1);}}this._aPosition.bindArrayBuffer(state.positionsBuf);if(this._aUV){this._aUV.bindArrayBuffer(state.uvBuf);}if(this._aNormal){this._aNormal.bindArrayBuffer(state.normalsBuf);}if(this._aMetallicRoughness){this._aMetallicRoughness.bindArrayBuffer(state.metallicRoughnessBuf);if(this._instancing){gl.vertexAttribDivisor(this._aMetallicRoughness.location,1);}}if(this._aColor){this._aColor.bindArrayBuffer(state.colorsBuf);if(this._instancing&&state.colorsBuf){gl.vertexAttribDivisor(this._aColor.location,1);}}if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aFlags.location,1);}}if(this._aOffset){this._aOffset.bindArrayBuffer(state.offsetsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aOffset.location,1);}}if(this._aPickColor){this._aPickColor.bindArrayBuffer(state.pickColorsBuf);if(this._instancing){gl.vertexAttribDivisor(this._aPickColor.location,1);}}if(this._instancing){if(this._edges){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}else{if(this._edges){state.edgeIndicesBuf.bind();}else{if(state.indicesBuf){state.indicesBuf.bind();}}}return vao;}},{key:"drawLayer",value:function drawLayer(frameCtx,layer,renderPass){var _ref9=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{},_ref9$colorUniform=_ref9.colorUniform,colorUniform=_ref9$colorUniform===void 0?false:_ref9$colorUniform,_ref9$incrementDrawSt=_ref9.incrementDrawState,incrementDrawState=_ref9$incrementDrawSt===void 0?false:_ref9$incrementDrawSt;var maxTextureUnits=WEBGL_INFO.MAX_TEXTURE_IMAGE_UNITS;var scene=this._scene;var gl=scene.canvas.gl;var state=layer._state,model=layer.model;var textureSet=state.textureSet,origin=state.origin,positionsDecodeMatrix=state.positionsDecodeMatrix;var lightsState=scene._lightsState;var pointsMaterial=scene.pointsMaterial;var camera=model.scene.camera;var viewNormalMatrix=camera.viewNormalMatrix,project=camera.project;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate,worldNormalMatrix=model.worldNormalMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx);}if(this._vaoCache.has(layer)){gl.bindVertexArray(this._vaoCache.get(layer));}else{this._vaoCache.set(layer,this._makeVAO(state));}var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$s;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$k);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];this._matricesUniformBlockBufferData.set(createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$h),offset+=mat4Size);}else{this._matricesUniformBlockBufferData.set(viewMatrix,offset+=mat4Size);}this._matricesUniformBlockBufferData.set(frameCtx.pickProjMatrix||project.matrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(positionsDecodeMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(worldNormalMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(viewNormalMatrix,offset+=mat4Size);gl.bindBuffer(gl.UNIFORM_BUFFER,this._matricesUniformBlockBuffer);gl.bufferData(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferData,gl.DYNAMIC_DRAW);gl.bindBufferBase(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferBindingPoint,this._matricesUniformBlockBuffer);gl.uniform1i(this._uRenderPass,renderPass);this.setSectionPlanesStateUniforms(layer);if(scene.logarithmicDepthBufferEnabled){if(this._uLogDepthBufFC){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
|
|
17280
17280
|
gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}if(this._uZFar){gl.uniform1f(this._uZFar,scene.camera.project.far);}}if(this._uPickInvisible){gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);}if(this._uPickZNear){gl.uniform1f(this._uPickZNear,frameCtx.pickZNear);}if(this._uPickZFar){gl.uniform1f(this._uPickZFar,frameCtx.pickZFar);}if(this._uPickClipPos){gl.uniform2fv(this._uPickClipPos,frameCtx.pickClipPos);}if(this._uDrawingBufferSize){gl.uniform2f(this._uDrawingBufferSize,gl.drawingBufferWidth,gl.drawingBufferHeight);}if(this._uUVDecodeMatrix){gl.uniformMatrix3fv(this._uUVDecodeMatrix,false,state.uvDecodeMatrix);}if(this._uIntensityRange&&pointsMaterial.filterIntensity){gl.uniform2f(this._uIntensityRange,pointsMaterial.minIntensity,pointsMaterial.maxIntensity);}if(this._uPointSize){gl.uniform1f(this._uPointSize,pointsMaterial.pointSize);}if(this._uNearPlaneHeight){var nearPlaneHeight=scene.camera.projection==="ortho"?1.0:gl.drawingBufferHeight/(2*Math.tan(0.5*scene.camera.perspective.fov*Math.PI/180.0));gl.uniform1f(this._uNearPlaneHeight,nearPlaneHeight);}if(textureSet){var colorTexture=textureSet.colorTexture,metallicRoughnessTexture=textureSet.metallicRoughnessTexture,emissiveTexture=textureSet.emissiveTexture,normalsTexture=textureSet.normalsTexture,occlusionTexture=textureSet.occlusionTexture;if(this._uColorMap&&colorTexture){this._program.bindTexture(this._uColorMap,colorTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uMetallicRoughMap&&metallicRoughnessTexture){this._program.bindTexture(this._uMetallicRoughMap,metallicRoughnessTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uEmissiveMap&&emissiveTexture){this._program.bindTexture(this._uEmissiveMap,emissiveTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uNormalMap&&normalsTexture){this._program.bindTexture(this._uNormalMap,normalsTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}if(this._uAOMap&&occlusionTexture){this._program.bindTexture(this._uAOMap,occlusionTexture.texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;}}if(lightsState.reflectionMaps.length>0&&lightsState.reflectionMaps[0].texture&&this._uReflectionMap){this._program.bindTexture(this._uReflectionMap,lightsState.reflectionMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(lightsState.lightMaps.length>0&&lightsState.lightMaps[0].texture&&this._uLightMap){this._program.bindTexture(this._uLightMap,lightsState.lightMaps[0].texture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4[0]=viewportWidth;tempVec4[1]=viewportHeight;tempVec4[2]=sao.blendCutoff;tempVec4[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,frameCtx.textureUnit);frameCtx.textureUnit=(frameCtx.textureUnit+1)%maxTextureUnits;frameCtx.bindTexture++;}}if(colorUniform){var colorKey=this._edges?"edgeColor":"fillColor";var alphaKey=this._edges?"edgeAlpha":"fillAlpha";if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_XRAYED")]){var material=scene.xrayMaterial._state;var _color3=material[colorKey];var alpha=material[alphaKey];gl.uniform4f(this._uColor,_color3[0],_color3[1],_color3[2],alpha);}else if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_HIGHLIGHTED")]){var _material=scene.highlightMaterial._state;var _color4=_material[colorKey];var _alpha=_material[alphaKey];gl.uniform4f(this._uColor,_color4[0],_color4[1],_color4[2],_alpha);}else if(renderPass===RENDER_PASSES["".concat(this._edges?"EDGES":"SILHOUETTE","_SELECTED")]){var _material2=scene.selectedMaterial._state;var _color5=_material2[colorKey];var _alpha2=_material2[alphaKey];gl.uniform4f(this._uColor,_color5[0],_color5[1],_color5[2],_alpha2);}else{gl.uniform4fv(this._uColor,this._edges?edgesDefaultColor:defaultColor$2);}}this._draw({state:state,frameCtx:frameCtx,incrementDrawState:incrementDrawState});gl.bindVertexArray(null);}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;stats.memory.programs--;}}]);return VBOSceneModelRenderer;}();/**
|
|
17281
17281
|
* @private
|
|
17282
17282
|
*/var VBOSceneModelTriangleBatchingRenderer=/*#__PURE__*/function(_VBOSceneModelRendere){_inherits(VBOSceneModelTriangleBatchingRenderer,_VBOSceneModelRendere);var _super66=_createSuper(VBOSceneModelTriangleBatchingRenderer);function VBOSceneModelTriangleBatchingRenderer(scene,withSAO){var _ref10=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},_ref10$instancing=_ref10.instancing,instancing=_ref10$instancing===void 0?false:_ref10$instancing,_ref10$edges=_ref10.edges,edges=_ref10$edges===void 0?false:_ref10$edges;_classCallCheck(this,VBOSceneModelTriangleBatchingRenderer);return _super66.call(this,scene,withSAO,{instancing:instancing,edges:edges});}_createClass(VBOSceneModelTriangleBatchingRenderer,[{key:"_draw",value:function _draw(drawCfg){var gl=this._scene.canvas.gl;var state=drawCfg.state,frameCtx=drawCfg.frameCtx,incrementDrawState=drawCfg.incrementDrawState;if(this._edges){gl.drawElements(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0);}else{var count=frameCtx.pickElementsCount||state.indicesBuf.numItems;var offset=frameCtx.pickElementsOffset?frameCtx.pickElementsOffset*state.indicesBuf.itemByteSize:0;gl.drawElements(gl.TRIANGLES,count,state.indicesBuf.itemType,offset);if(incrementDrawState){frameCtx.drawElements++;}}}}]);return VBOSceneModelTriangleBatchingRenderer;}(VBOSceneModelRenderer);/**
|
|
@@ -17426,18 +17426,18 @@ best=oct=octEncodeVec3(worldNormal,"floor","floor");dec=octDecodeVec2(oct);curre
|
|
|
17426
17426
|
var x=p[0]/(Math.abs(p[0])+Math.abs(p[1])+Math.abs(p[2]));var y=p[1]/(Math.abs(p[0])+Math.abs(p[1])+Math.abs(p[2]));if(p[2]<0){var tempx=x;var tempy=y;tempx=(1-Math.abs(y))*(x>=0?1:-1);tempy=(1-Math.abs(x))*(y>=0?1:-1);x=tempx;y=tempy;}return new Int8Array([Math[xfunc](x*127.5+(x<0?-1:0)),Math[yfunc](y*127.5+(y<0?-1:0))]);}/**
|
|
17427
17427
|
* @private
|
|
17428
17428
|
*/function octDecodeVec2(oct){// Decode an oct-encoded normal
|
|
17429
|
-
var x=oct[0];var y=oct[1];x/=x<0?127:128;y/=y<0?127:128;var z=1-Math.abs(x)-Math.abs(y);if(z<0){x=(1-Math.abs(y))*(x>=0?1:-1);y=(1-Math.abs(x))*(y>=0?1:-1);}var length=Math.sqrt(x*x+y*y+z*z);return[x/length,y/length,z/length];}var tempVec3a$r=math.vec3();var tempVec3b$n=math.vec3();var tempVec3c$
|
|
17429
|
+
var x=oct[0];var y=oct[1];x/=x<0?127:128;y/=y<0?127:128;var z=1-Math.abs(x)-Math.abs(y);if(z<0){x=(1-Math.abs(y))*(x>=0?1:-1);y=(1-Math.abs(x))*(y>=0?1:-1);}var length=Math.sqrt(x*x+y*y+z*z);return[x/length,y/length,z/length];}var tempVec3a$r=math.vec3();var tempVec3b$n=math.vec3();var tempVec3c$j=math.vec3();var tempVec3d$8=math.vec3();var tempMat4a$g=math.mat4();/**
|
|
17430
17430
|
* @private
|
|
17431
|
-
*/var SnapBatchingDepthBufInitRenderer=/*#__PURE__*/function(_VBOSceneModelRendere7){_inherits(SnapBatchingDepthBufInitRenderer,_VBOSceneModelRendere7);var _super89=_createSuper(SnapBatchingDepthBufInitRenderer);function SnapBatchingDepthBufInitRenderer(){_classCallCheck(this,SnapBatchingDepthBufInitRenderer);return _super89.apply(this,arguments);}_createClass(SnapBatchingDepthBufInitRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=batchingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=batchingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(batchingLayer)){gl.bindVertexArray(this._vaoCache.get(batchingLayer));}else{this._vaoCache.set(batchingLayer,this._makeVAO(state));}var coordinateScaler=tempVec3a$r;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$n;if(origin){var rotatedOrigin=tempVec3c$
|
|
17431
|
+
*/var SnapBatchingDepthBufInitRenderer=/*#__PURE__*/function(_VBOSceneModelRendere7){_inherits(SnapBatchingDepthBufInitRenderer,_VBOSceneModelRendere7);var _super89=_createSuper(SnapBatchingDepthBufInitRenderer);function SnapBatchingDepthBufInitRenderer(){_classCallCheck(this,SnapBatchingDepthBufInitRenderer);return _super89.apply(this,arguments);}_createClass(SnapBatchingDepthBufInitRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=batchingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=batchingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(batchingLayer)){gl.bindVertexArray(this._vaoCache.get(batchingLayer));}else{this._vaoCache.set(batchingLayer,this._makeVAO(state));}var coordinateScaler=tempVec3a$r;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$n;if(origin){var rotatedOrigin=tempVec3c$j;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$g);rtcCameraEye=tempVec3d$8;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,offset+=mat4Size);gl.bindBuffer(gl.UNIFORM_BUFFER,this._matricesUniformBlockBuffer);gl.bufferData(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferData,gl.DYNAMIC_DRAW);gl.bindBufferBase(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferBindingPoint,this._matricesUniformBlockBuffer);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
|
|
17432
17432
|
gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(batchingLayer);//=============================================================
|
|
17433
17433
|
// TODO: Use drawElements count and offset to draw only one entity
|
|
17434
17434
|
//=============================================================
|
|
17435
17435
|
state.indicesBuf.bind();gl.drawElements(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0);state.indicesBuf.unbind();}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(SnapBatchingDepthBufInitRenderer.prototype),"_allocate",this).call(this);var program=this._program;{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// VBO SnapBatchingDepthBufInitRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");src.push("in vec4 pickColor;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");{src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");src.push("flat out vec4 vPickColor;");src.push("out vec4 vWorldPosition;");if(clipping){src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
|
|
17436
17436
|
// renderPass = PICK
|
|
17437
17437
|
src.push("int pickFlag = int(flags) >> 12 & 0xF;");src.push("if (pickFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
|
|
17438
|
-
src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}src.push("vPickColor = pickColor;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// VBO SnapBatchingDepthBufInitRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("in float vFlags;");for(var _i203=0;_i203<sectionPlanesState.getNumAllocatedSectionPlanes();_i203++){src.push("uniform bool sectionPlaneActive"+_i203+";");src.push("uniform vec3 sectionPlanePos"+_i203+";");src.push("uniform vec3 sectionPlaneDir"+_i203+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return SnapBatchingDepthBufInitRenderer;}(VBOSceneModelRenderer);var tempVec3a$q=math.vec3();var tempVec3b$m=math.vec3();var tempVec3c$
|
|
17438
|
+
src.push(" } else {");src.push(" vec4 worldPosition = worldMatrix * (positionsDecodeMatrix * vec4(position, 1.0)); ");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push(" relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}src.push("vPickColor = pickColor;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// VBO SnapBatchingDepthBufInitRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("in float vFlags;");for(var _i203=0;_i203<sectionPlanesState.getNumAllocatedSectionPlanes();_i203++){src.push("uniform bool sectionPlaneActive"+_i203+";");src.push("uniform vec3 sectionPlanePos"+_i203+";");src.push("uniform vec3 sectionPlaneDir"+_i203+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var i=0;i<sectionPlanesState.getNumAllocatedSectionPlanes();i++){src.push(" if (sectionPlaneActive"+i+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+i+".xyz, vWorldPosition.xyz - sectionPlanePos"+i+".xyz), 0.0, 1000.0);");src.push(" }");}src.push(" if (dist > 0.0) { discard; }");src.push(" }");}{src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return SnapBatchingDepthBufInitRenderer;}(VBOSceneModelRenderer);var tempVec3a$q=math.vec3();var tempVec3b$m=math.vec3();var tempVec3c$i=math.vec3();var tempVec3d$7=math.vec3();var tempMat4a$f=math.mat4();/**
|
|
17439
17439
|
* @private
|
|
17440
|
-
*/var SnapBatchingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelRendere8){_inherits(SnapBatchingDepthRenderer,_VBOSceneModelRendere8);var _super90=_createSuper(SnapBatchingDepthRenderer);function SnapBatchingDepthRenderer(){_classCallCheck(this,SnapBatchingDepthRenderer);return _super90.apply(this,arguments);}_createClass(SnapBatchingDepthRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=batchingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=batchingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(batchingLayer)){gl.bindVertexArray(this._vaoCache.get(batchingLayer));}else{this._vaoCache.set(batchingLayer,this._makeVAO(state));}var coordinateScaler=tempVec3a$q;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$m;if(origin){var rotatedOrigin=tempVec3c$
|
|
17440
|
+
*/var SnapBatchingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelRendere8){_inherits(SnapBatchingDepthRenderer,_VBOSceneModelRendere8);var _super90=_createSuper(SnapBatchingDepthRenderer);function SnapBatchingDepthRenderer(){_classCallCheck(this,SnapBatchingDepthRenderer);return _super90.apply(this,arguments);}_createClass(SnapBatchingDepthRenderer,[{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash()+this._scene.pointsMaterial.hash;}},{key:"drawLayer",value:function drawLayer(frameCtx,batchingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=batchingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=batchingLayer._state;var origin=batchingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=batchingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(batchingLayer)){gl.bindVertexArray(this._vaoCache.get(batchingLayer));}else{this._vaoCache.set(batchingLayer,this._makeVAO(state));}var coordinateScaler=tempVec3a$q;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$m;if(origin){var rotatedOrigin=tempVec3c$i;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$f);rtcCameraEye=tempVec3d$7;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,offset+=mat4Size);gl.bindBuffer(gl.UNIFORM_BUFFER,this._matricesUniformBlockBuffer);gl.bufferData(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferData,gl.DYNAMIC_DRAW);gl.bindBufferBase(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferBindingPoint,this._matricesUniformBlockBuffer);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix?
|
|
17441
17441
|
gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(batchingLayer);//=============================================================
|
|
17442
17442
|
// TODO: Use drawElements count and offset to draw only one entity
|
|
17443
17443
|
//=============================================================
|
|
@@ -17453,7 +17453,7 @@ src.push(" }");src.push("}");return src;}},{key:"_buildFragmentShader",value:fu
|
|
|
17453
17453
|
// when user first begins interacting with the viewer.
|
|
17454
17454
|
if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapBatchingDepthBufInitRenderer(this._scene,false);}if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapBatchingDepthRenderer(this._scene);}}},{key:"snapDepthBufInitRenderer",get:function get(){if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapBatchingDepthBufInitRenderer(this._scene,false);}return this._snapDepthBufInitRenderer;}},{key:"snapDepthRenderer",get:function get(){if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapBatchingDepthRenderer(this._scene);}return this._snapDepthRenderer;}},{key:"_destroy",value:function _destroy(){if(this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer.destroy();}if(this._snapDepthRenderer){this._snapDepthRenderer.destroy();}}}]);return SnapBatchingRenderers;}();var cachedRenderers$6={};/**
|
|
17455
17455
|
* @private
|
|
17456
|
-
*/function getSnapBatchingRenderers(scene){var sceneId=scene.id;var batchingRenderers=cachedRenderers$6[sceneId];if(!batchingRenderers){batchingRenderers=new SnapBatchingRenderers(scene);cachedRenderers$6[sceneId]=batchingRenderers;batchingRenderers._compile();batchingRenderers.eagerCreateRenders();scene.on("compile",function(){batchingRenderers._compile();batchingRenderers.eagerCreateRenders();});scene.on("destroyed",function(){delete cachedRenderers$6[sceneId];batchingRenderers._destroy();});}return batchingRenderers;}var tempMat4$1=math.mat4();var tempMat4b=math.mat4();var tempVec4a$c=math.vec4([0,0,0,1]);var tempVec4b$b=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);math.OBB3();var tempVec3a$p=math.vec3();var tempVec3b$l=math.vec3();var tempVec3c$
|
|
17456
|
+
*/function getSnapBatchingRenderers(scene){var sceneId=scene.id;var batchingRenderers=cachedRenderers$6[sceneId];if(!batchingRenderers){batchingRenderers=new SnapBatchingRenderers(scene);cachedRenderers$6[sceneId]=batchingRenderers;batchingRenderers._compile();batchingRenderers.eagerCreateRenders();scene.on("compile",function(){batchingRenderers._compile();batchingRenderers.eagerCreateRenders();});scene.on("destroyed",function(){delete cachedRenderers$6[sceneId];batchingRenderers._destroy();});}return batchingRenderers;}var tempMat4$1=math.mat4();var tempMat4b=math.mat4();var tempVec4a$c=math.vec4([0,0,0,1]);var tempVec4b$b=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);math.OBB3();var tempVec3a$p=math.vec3();var tempVec3b$l=math.vec3();var tempVec3c$h=math.vec3();var tempVec3d$6=math.vec3();var tempVec3e$1=math.vec3();var tempVec3f$1=math.vec3();var tempVec3g$1=math.vec3();/**
|
|
17457
17457
|
* @private
|
|
17458
17458
|
*/var TrianglesBatchingLayer=/*#__PURE__*/function(){/**
|
|
17459
17459
|
* @param model
|
|
@@ -17548,7 +17548,7 @@ return;}var portionsIdx=portionId;var portion=this._portions[portionsIdx];var ve
|
|
|
17548
17548
|
// } else {
|
|
17549
17549
|
if(this._batchingRenderers.pickNormalsFlatRenderer){this._batchingRenderers.pickNormalsFlatRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}// }
|
|
17550
17550
|
}},{key:"drawSnapInitDepthBuf",value:function drawSnapInitDepthBuf(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._snapBatchingRenderers.snapDepthBufInitRenderer){this._snapBatchingRenderers.snapDepthBufInitRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}},{key:"drawSnapDepths",value:function drawSnapDepths(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._snapBatchingRenderers.snapDepthRenderer){this._snapBatchingRenderers.snapDepthRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}//------------------------------------------------------------------------------------------------
|
|
17551
|
-
},{key:"precisionRayPickSurface",value:function precisionRayPickSurface(portionId,worldRayOrigin,worldRayDir,worldSurfacePos,worldNormal){if(!this.model.scene.pickSurfacePrecisionEnabled){return false;}var state=this._state;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return false;}var positions=portion.quantizedPositions;var indices=portion.indices;var origin=state.origin;var offset=portion.offset;var rtcRayOrigin=tempVec3a$p;var rtcRayDir=tempVec3b$l;rtcRayOrigin.set(origin?math.subVec3(worldRayOrigin,origin,tempVec3c$
|
|
17551
|
+
},{key:"precisionRayPickSurface",value:function precisionRayPickSurface(portionId,worldRayOrigin,worldRayDir,worldSurfacePos,worldNormal){if(!this.model.scene.pickSurfacePrecisionEnabled){return false;}var state=this._state;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return false;}var positions=portion.quantizedPositions;var indices=portion.indices;var origin=state.origin;var offset=portion.offset;var rtcRayOrigin=tempVec3a$p;var rtcRayDir=tempVec3b$l;rtcRayOrigin.set(origin?math.subVec3(worldRayOrigin,origin,tempVec3c$h):worldRayOrigin);// World -> RTC
|
|
17552
17552
|
rtcRayDir.set(worldRayDir);if(offset){math.subVec3(rtcRayOrigin,offset);}math.transformRay(this.model.worldNormalMatrix,rtcRayOrigin,rtcRayDir,rtcRayOrigin,rtcRayDir);// RTC -> local
|
|
17553
17553
|
var a=tempVec3d$6;var b=tempVec3e$1;var c=tempVec3f$1;var gotIntersect=false;var closestDist=0;var closestIntersectPos=tempVec3g$1;for(var _i226=0,len=indices.length;_i226<len;_i226+=3){var ia=indices[_i226]*3;var ib=indices[_i226+1]*3;var ic=indices[_i226+2]*3;a[0]=positions[ia];a[1]=positions[ia+1];a[2]=positions[ia+2];b[0]=positions[ib];b[1]=positions[ib+1];b[2]=positions[ib+2];c[0]=positions[ic];c[1]=positions[ic+1];c[2]=positions[ic+2];math.decompressPosition(a,state.positionsDecodeMatrix);math.decompressPosition(b,state.positionsDecodeMatrix);math.decompressPosition(c,state.positionsDecodeMatrix);if(math.rayTriangleIntersect(rtcRayOrigin,rtcRayDir,a,b,c,closestIntersectPos)){math.transformPoint3(this.model.worldMatrix,closestIntersectPos,closestIntersectPos);if(offset){math.addVec3(closestIntersectPos,offset);}if(origin){math.addVec3(closestIntersectPos,origin);}var dist=Math.abs(math.lenVec3(math.subVec3(closestIntersectPos,worldRayOrigin,[])));if(!gotIntersect||dist>closestDist){closestDist=dist;worldSurfacePos.set(closestIntersectPos);if(worldNormal){// Not that wasteful to eagerly compute - unlikely to hit >2 surfaces on most geometry
|
|
17554
17554
|
math.triangleNormal(a,b,c,worldNormal);}gotIntersect=true;}}}if(gotIntersect&&worldNormal){math.transformVec3(this.model.worldNormalMatrix,worldNormal,worldNormal);math.normalizeVec3(worldNormal);}return gotIntersect;}// ---------
|
|
@@ -17671,16 +17671,16 @@ src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewp
|
|
|
17671
17671
|
if(!this._silhouetteRenderer){// Used for highlighting and selection
|
|
17672
17672
|
this._silhouetteRenderer=new TrianglesInstancingSilhouetteRenderer(this._scene);}if(!this._pickMeshRenderer){this._pickMeshRenderer=new TrianglesInstancingPickMeshRenderer(this._scene);}if(!this._pickDepthRenderer){this._pickDepthRenderer=new TrianglesInstancingPickDepthRenderer(this._scene);}}},{key:"colorRenderer",get:function get(){if(!this._colorRenderer){this._colorRenderer=new TrianglesInstancingColorRenderer(this._scene,false);}return this._colorRenderer;}},{key:"colorRendererWithSAO",get:function get(){if(!this._colorRendererWithSAO){this._colorRendererWithSAO=new TrianglesInstancingColorRenderer(this._scene,true);}return this._colorRendererWithSAO;}},{key:"flatColorRenderer",get:function get(){if(!this._flatColorRenderer){this._flatColorRenderer=new TrianglesInstancingFlatColorRenderer(this._scene,false);}return this._flatColorRenderer;}},{key:"flatColorRendererWithSAO",get:function get(){if(!this._flatColorRendererWithSAO){this._flatColorRendererWithSAO=new TrianglesInstancingFlatColorRenderer(this._scene,true);}return this._flatColorRendererWithSAO;}},{key:"pbrRenderer",get:function get(){if(!this._pbrRenderer){this._pbrRenderer=new TrianglesInstancingPBRRenderer(this._scene,false);}return this._pbrRenderer;}},{key:"pbrRendererWithSAO",get:function get(){if(!this._pbrRendererWithSAO){this._pbrRendererWithSAO=new TrianglesInstancingPBRRenderer(this._scene,true);}return this._pbrRendererWithSAO;}},{key:"colorTextureRenderer",get:function get(){if(!this._colorTextureRenderer){this._colorTextureRenderer=new TrianglesInstancingColorTextureRenderer(this._scene,false);}return this._colorTextureRenderer;}},{key:"colorTextureRendererWithSAO",get:function get(){if(!this._colorTextureRendererWithSAO){this._colorTextureRendererWithSAO=new TrianglesInstancingColorTextureRenderer(this._scene,true);}return this._colorTextureRendererWithSAO;}},{key:"silhouetteRenderer",get:function get(){if(!this._silhouetteRenderer){this._silhouetteRenderer=new TrianglesInstancingSilhouetteRenderer(this._scene);}return this._silhouetteRenderer;}},{key:"depthRenderer",get:function get(){if(!this._depthRenderer){this._depthRenderer=new TrianglesInstancingDepthRenderer(this._scene);}return this._depthRenderer;}},{key:"normalsRenderer",get:function get(){if(!this._normalsRenderer){this._normalsRenderer=new TrianglesInstancingNormalsRenderer(this._scene);}return this._normalsRenderer;}},{key:"edgesRenderer",get:function get(){if(!this._edgesRenderer){this._edgesRenderer=new TrianglesInstancingEdgesRenderer(this._scene);}return this._edgesRenderer;}},{key:"edgesColorRenderer",get:function get(){if(!this._edgesColorRenderer){this._edgesColorRenderer=new TrianglesInstancingEdgesColorRenderer(this._scene);}return this._edgesColorRenderer;}},{key:"pickMeshRenderer",get:function get(){if(!this._pickMeshRenderer){this._pickMeshRenderer=new TrianglesInstancingPickMeshRenderer(this._scene);}return this._pickMeshRenderer;}},{key:"pickNormalsRenderer",get:function get(){if(!this._pickNormalsRenderer){this._pickNormalsRenderer=new TrianglesInstancingPickNormalsRenderer(this._scene);}return this._pickNormalsRenderer;}},{key:"pickNormalsFlatRenderer",get:function get(){if(!this._pickNormalsFlatRenderer){this._pickNormalsFlatRenderer=new TrianglesInstancingPickNormalsFlatRenderer(this._scene);}return this._pickNormalsFlatRenderer;}},{key:"pickDepthRenderer",get:function get(){if(!this._pickDepthRenderer){this._pickDepthRenderer=new TrianglesInstancingPickDepthRenderer(this._scene);}return this._pickDepthRenderer;}},{key:"occlusionRenderer",get:function get(){if(!this._occlusionRenderer){this._occlusionRenderer=new TrianglesInstancingOcclusionRenderer(this._scene);}return this._occlusionRenderer;}},{key:"shadowRenderer",get:function get(){if(!this._shadowRenderer){this._shadowRenderer=new TrianglesInstancingShadowRenderer(this._scene);}return this._shadowRenderer;}},{key:"_destroy",value:function _destroy(){if(this._colorRenderer){this._colorRenderer.destroy();}if(this._colorRendererWithSAO){this._colorRendererWithSAO.destroy();}if(this._flatColorRenderer){this._flatColorRenderer.destroy();}if(this._flatColorRendererWithSAO){this._flatColorRendererWithSAO.destroy();}if(this._pbrRenderer){this._pbrRenderer.destroy();}if(this._pbrRendererWithSAO){this._pbrRendererWithSAO.destroy();}if(this._colorTextureRenderer){this._colorTextureRenderer.destroy();}if(this._colorTextureRendererWithSAO){this._colorTextureRendererWithSAO.destroy();}if(this._depthRenderer){this._depthRenderer.destroy();}if(this._normalsRenderer){this._normalsRenderer.destroy();}if(this._silhouetteRenderer){this._silhouetteRenderer.destroy();}if(this._edgesRenderer){this._edgesRenderer.destroy();}if(this._edgesColorRenderer){this._edgesColorRenderer.destroy();}if(this._pickMeshRenderer){this._pickMeshRenderer.destroy();}if(this._pickDepthRenderer){this._pickDepthRenderer.destroy();}if(this._pickNormalsRenderer){this._pickNormalsRenderer.destroy();}if(this._pickNormalsFlatRenderer){this._pickNormalsFlatRenderer.destroy();}if(this._occlusionRenderer){this._occlusionRenderer.destroy();}if(this._shadowRenderer){this._shadowRenderer.destroy();}}}]);return TrianglesInstancingRenderers;}();var cachedRenderers$5={};/**
|
|
17673
17673
|
* @private
|
|
17674
|
-
*/function getInstancingRenderers$1(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$5[sceneId];if(!instancingRenderers){instancingRenderers=new TrianglesInstancingRenderers(scene);cachedRenderers$5[sceneId]=instancingRenderers;instancingRenderers._compile();instancingRenderers.eagerCreateRenders();scene.on("compile",function(){instancingRenderers._compile();instancingRenderers.eagerCreateRenders();});scene.on("destroyed",function(){delete cachedRenderers$5[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempVec3a$o=math.vec3();var tempVec3b$k=math.vec3();var tempVec3c$
|
|
17674
|
+
*/function getInstancingRenderers$1(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$5[sceneId];if(!instancingRenderers){instancingRenderers=new TrianglesInstancingRenderers(scene);cachedRenderers$5[sceneId]=instancingRenderers;instancingRenderers._compile();instancingRenderers.eagerCreateRenders();scene.on("compile",function(){instancingRenderers._compile();instancingRenderers.eagerCreateRenders();});scene.on("destroyed",function(){delete cachedRenderers$5[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempVec3a$o=math.vec3();var tempVec3b$k=math.vec3();var tempVec3c$g=math.vec3();var tempVec3d$5=math.vec3();var tempMat4a$e=math.mat4();/**
|
|
17675
17675
|
* @private
|
|
17676
|
-
*/var SnapInstancingDepthBufInitRenderer=/*#__PURE__*/function(_VBOSceneModelRendere9){_inherits(SnapInstancingDepthBufInitRenderer,_VBOSceneModelRendere9);var _super106=_createSuper(SnapInstancingDepthBufInitRenderer);function SnapInstancingDepthBufInitRenderer(scene){_classCallCheck(this,SnapInstancingDepthBufInitRenderer);return _super106.call(this,scene,false,{instancing:true});}_createClass(SnapInstancingDepthBufInitRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=instancingLayer.model;var scene=model.scene;var gl=scene.canvas.gl;var camera=scene.camera;var state=instancingLayer._state;var origin=instancingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=instancingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(instancingLayer)){gl.bindVertexArray(this._vaoCache.get(instancingLayer));}else{this._vaoCache.set(instancingLayer,this._makeVAO(state));}var coordinateScaler=tempVec3a$o;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$k;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$
|
|
17676
|
+
*/var SnapInstancingDepthBufInitRenderer=/*#__PURE__*/function(_VBOSceneModelRendere9){_inherits(SnapInstancingDepthBufInitRenderer,_VBOSceneModelRendere9);var _super106=_createSuper(SnapInstancingDepthBufInitRenderer);function SnapInstancingDepthBufInitRenderer(scene){_classCallCheck(this,SnapInstancingDepthBufInitRenderer);return _super106.call(this,scene,false,{instancing:true});}_createClass(SnapInstancingDepthBufInitRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=instancingLayer.model;var scene=model.scene;var gl=scene.canvas.gl;var camera=scene.camera;var state=instancingLayer._state;var origin=instancingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=instancingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(instancingLayer)){gl.bindVertexArray(this._vaoCache.get(instancingLayer));}else{this._vaoCache.set(instancingLayer,this._makeVAO(state));}var coordinateScaler=tempVec3a$o;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$k;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$g);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$e);rtcCameraEye=tempVec3d$5;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,offset+=mat4Size);gl.bindBuffer(gl.UNIFORM_BUFFER,this._matricesUniformBlockBuffer);gl.bufferData(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferData,gl.DYNAMIC_DRAW);gl.bindBufferBase(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferBindingPoint,this._matricesUniformBlockBuffer);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(instancingLayer);this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);if(this._aFlags){this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);}state.indicesBuf.bind();gl.drawElementsInstanced(gl.TRIANGLES,state.indicesBuf.numItems,state.indicesBuf.itemType,0,state.numInstances);state.indicesBuf.unbind();// Cleanup
|
|
17677
17677
|
gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);if(this._aFlags){gl.vertexAttribDivisor(this._aFlags.location,0);}if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(SnapInstancingDepthBufInitRenderer.prototype),"_allocate",this).call(this);var program=this._program;{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// SnapInstancingDepthBufInitRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");src.push("in vec4 pickColor;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
|
|
17678
17678
|
src.push("in vec4 modelMatrixCol1;");src.push("in vec4 modelMatrixCol2;");src.push("uniform bool pickInvisible;");this._addMatricesUniformBlockLines(src);src.push("uniform vec3 uCameraEyeRtc;");src.push("uniform vec2 snapVectorA;");src.push("uniform vec2 snapInvVectorAB;");{src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("out float isPerspective;");}src.push("vec2 remapClipPos(vec2 clipPos) {");src.push(" float x = (clipPos.x - snapVectorA.x) * snapInvVectorAB.x;");src.push(" float y = (clipPos.y - snapVectorA.y) * snapInvVectorAB.y;");src.push(" return vec2(x, y);");src.push("}");src.push("flat out vec4 vPickColor;");src.push("out vec4 vWorldPosition;");if(clipping){src.push("out float vFlags;");}src.push("out highp vec3 relativeToOriginPosition;");src.push("void main(void) {");// pickFlag = NOT_RENDERED | PICK
|
|
17679
17679
|
// renderPass = PICK
|
|
17680
17680
|
src.push("int pickFlag = int(flags) >> 12 & 0xF;");src.push("if (pickFlag != renderPass) {");src.push(" gl_Position = vec4(0.0, 0.0, 0.0, 0.0);");// Cull vertex
|
|
17681
|
-
src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}src.push("vPickColor = pickColor;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points instancing pick depth fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("in float vFlags;");for(var _i255=0;_i255<sectionPlanesState.getNumAllocatedSectionPlanes();_i255++){src.push("uniform bool sectionPlaneActive"+_i255+";");src.push("uniform vec3 sectionPlanePos"+_i255+";");src.push("uniform vec3 sectionPlaneDir"+_i255+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i256=0;_i256<sectionPlanesState.getNumAllocatedSectionPlanes();_i256++){src.push("if (sectionPlaneActive"+_i256+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i256+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i256+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}{src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return SnapInstancingDepthBufInitRenderer;}(VBOSceneModelRenderer);var tempVec3a$n=math.vec3();var tempVec3b$j=math.vec3();var tempVec3c$
|
|
17681
|
+
src.push("} else {");src.push(" vec4 worldPosition = positionsDecodeMatrix * vec4(position, 1.0); ");src.push(" worldPosition = worldMatrix * vec4(dot(worldPosition, modelMatrixCol0), dot(worldPosition, modelMatrixCol1), dot(worldPosition, modelMatrixCol2), 1.0);");if(scene.entityOffsetsEnabled){src.push(" worldPosition.xyz = worldPosition.xyz + offset;");}src.push("relativeToOriginPosition = worldPosition.xyz;");src.push(" vec4 viewPosition = viewMatrix * worldPosition; ");src.push(" vWorldPosition = worldPosition;");if(clipping){src.push(" vFlags = flags;");}src.push("vPickColor = pickColor;");src.push("vec4 clipPos = projMatrix * viewPosition;");src.push("float tmp = clipPos.w;");src.push("clipPos.xyzw /= tmp;");src.push("clipPos.xy = remapClipPos(clipPos.xy);");src.push("clipPos.xyzw *= tmp;");{src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Points instancing pick depth fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");{src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}src.push("uniform int layerNumber;");src.push("uniform vec3 coordinateScaler;");src.push("in vec4 vWorldPosition;");src.push("flat in vec4 vPickColor;");if(clipping){src.push("in float vFlags;");for(var _i255=0;_i255<sectionPlanesState.getNumAllocatedSectionPlanes();_i255++){src.push("uniform bool sectionPlaneActive"+_i255+";");src.push("uniform vec3 sectionPlanePos"+_i255+";");src.push("uniform vec3 sectionPlaneDir"+_i255+";");}}src.push("in highp vec3 relativeToOriginPosition;");src.push("layout(location = 0) out highp ivec4 outCoords;");src.push("layout(location = 1) out highp ivec4 outNormal;");src.push("layout(location = 2) out lowp uvec4 outPickColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = (int(vFlags) >> 16 & 0xF) == 1;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i256=0;_i256<sectionPlanesState.getNumAllocatedSectionPlanes();_i256++){src.push("if (sectionPlaneActive"+_i256+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i256+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i256+".xyz), 0.0, 1000.0);");src.push("}");}src.push("if (dist > 0.0) { discard; }");src.push("}");}{src.push(" float dx = dFdx(vFragDepth);");src.push(" float dy = dFdy(vFragDepth);");src.push(" float diff = sqrt(dx*dx+dy*dy);");src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth + diff ) * logDepthBufFC * 0.5;");}src.push("outCoords = ivec4(relativeToOriginPosition.xyz*coordinateScaler.xyz, -layerNumber);");src.push("vec3 xTangent = dFdx( vWorldPosition.xyz );");src.push("vec3 yTangent = dFdy( vWorldPosition.xyz );");src.push("vec3 worldNormal = normalize( cross( xTangent, yTangent ) );");src.push("outNormal = ivec4(worldNormal * float(".concat(math.MAX_INT,"), 1.0);"));src.push("outPickColor = uvec4(vPickColor);");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return SnapInstancingDepthBufInitRenderer;}(VBOSceneModelRenderer);var tempVec3a$n=math.vec3();var tempVec3b$j=math.vec3();var tempVec3c$f=math.vec3();var tempVec3d$4=math.vec3();var tempMat4a$d=math.mat4();/**
|
|
17682
17682
|
* @private
|
|
17683
|
-
*/var SnapInstancingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelRendere10){_inherits(SnapInstancingDepthRenderer,_VBOSceneModelRendere10);var _super107=_createSuper(SnapInstancingDepthRenderer);function SnapInstancingDepthRenderer(scene){_classCallCheck(this,SnapInstancingDepthRenderer);return _super107.call(this,scene,false,{instancing:true});}_createClass(SnapInstancingDepthRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){if(!this._program){this._allocate(instancingLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=instancingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=instancingLayer._state;var origin=instancingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=instancingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(instancingLayer)){gl.bindVertexArray(this._vaoCache.get(instancingLayer));}else{this._vaoCache.set(instancingLayer,this._makeVAO(state));}var coordinateScaler=tempVec3a$n;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$j;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$
|
|
17683
|
+
*/var SnapInstancingDepthRenderer=/*#__PURE__*/function(_VBOSceneModelRendere10){_inherits(SnapInstancingDepthRenderer,_VBOSceneModelRendere10);var _super107=_createSuper(SnapInstancingDepthRenderer);function SnapInstancingDepthRenderer(scene){_classCallCheck(this,SnapInstancingDepthRenderer);return _super107.call(this,scene,false,{instancing:true});}_createClass(SnapInstancingDepthRenderer,[{key:"drawLayer",value:function drawLayer(frameCtx,instancingLayer,renderPass){if(!this._program){this._allocate(instancingLayer);if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}var model=instancingLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=instancingLayer._state;var origin=instancingLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var aabb=instancingLayer.aabb;var viewMatrix=frameCtx.pickViewMatrix||camera.viewMatrix;if(this._vaoCache.has(instancingLayer)){gl.bindVertexArray(this._vaoCache.get(instancingLayer));}else{this._vaoCache.set(instancingLayer,this._makeVAO(state));}var coordinateScaler=tempVec3a$n;coordinateScaler[0]=math.safeInv(aabb[3]-aabb[0])*math.MAX_INT;coordinateScaler[1]=math.safeInv(aabb[4]-aabb[1])*math.MAX_INT;coordinateScaler[2]=math.safeInv(aabb[5]-aabb[2])*math.MAX_INT;frameCtx.snapPickCoordinateScale[0]=math.safeInv(coordinateScaler[0]);frameCtx.snapPickCoordinateScale[1]=math.safeInv(coordinateScaler[1]);frameCtx.snapPickCoordinateScale[2]=math.safeInv(coordinateScaler[2]);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3b$j;if(origin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3c$f);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$d);rtcCameraEye=tempVec3d$4;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];frameCtx.snapPickOrigin[0]=rtcOrigin[0];frameCtx.snapPickOrigin[1]=rtcOrigin[1];frameCtx.snapPickOrigin[2]=rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;frameCtx.snapPickOrigin[0]=0;frameCtx.snapPickOrigin[1]=0;frameCtx.snapPickOrigin[2]=0;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform2fv(this.uVectorA,frameCtx.snapVectorA);gl.uniform2fv(this.uInverseVectorAB,frameCtx.snapInvVectorAB);gl.uniform1i(this._uLayerNumber,frameCtx.snapPickLayerNumber);gl.uniform3fv(this._uCoordinateScaler,coordinateScaler);gl.uniform1i(this._uRenderPass,renderPass);gl.uniform1i(this._uPickInvisible,frameCtx.pickInvisible);var offset=0;var mat4Size=4*4;this._matricesUniformBlockBufferData.set(rotationMatrixConjugate,0);this._matricesUniformBlockBufferData.set(rtcViewMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(camera.projMatrix,offset+=mat4Size);this._matricesUniformBlockBufferData.set(state.positionsDecodeMatrix,offset+=mat4Size);gl.bindBuffer(gl.UNIFORM_BUFFER,this._matricesUniformBlockBuffer);gl.bufferData(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferData,gl.DYNAMIC_DRAW);gl.bindBufferBase(gl.UNIFORM_BUFFER,this._matricesUniformBlockBufferBindingPoint,this._matricesUniformBlockBuffer);{var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);// TODO: Far from pick project matrix
|
|
17684
17684
|
gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}this.setSectionPlanesStateUniforms(instancingLayer);this._aModelMatrixCol0.bindArrayBuffer(state.modelMatrixCol0Buf);this._aModelMatrixCol1.bindArrayBuffer(state.modelMatrixCol1Buf);this._aModelMatrixCol2.bindArrayBuffer(state.modelMatrixCol2Buf);gl.vertexAttribDivisor(this._aModelMatrixCol0.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,1);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,1);this._aFlags.bindArrayBuffer(state.flagsBuf);gl.vertexAttribDivisor(this._aFlags.location,1);if(frameCtx.snapMode==="edge"){state.edgeIndicesBuf.bind();gl.drawElementsInstanced(gl.LINES,state.edgeIndicesBuf.numItems,state.edgeIndicesBuf.itemType,0,state.numInstances);state.edgeIndicesBuf.unbind();// needed?
|
|
17685
17685
|
}else{gl.drawArraysInstanced(gl.POINTS,0,state.positionsBuf.numItems,state.numInstances);}// Cleanup
|
|
17686
17686
|
gl.vertexAttribDivisor(this._aModelMatrixCol0.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol1.location,0);gl.vertexAttribDivisor(this._aModelMatrixCol2.location,0);gl.vertexAttribDivisor(this._aFlags.location,0);if(this._aOffset){gl.vertexAttribDivisor(this._aOffset.location,0);}}},{key:"_allocate",value:function _allocate(){_get(_getPrototypeOf(SnapInstancingDepthRenderer.prototype),"_allocate",this).call(this);var program=this._program;{this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");this.uVectorA=program.getLocation("snapVectorA");this.uInverseVectorAB=program.getLocation("snapInvVectorAB");this._uLayerNumber=program.getLocation("layerNumber");this._uCoordinateScaler=program.getLocation("coordinateScaler");}},{key:"_bindProgram",value:function _bindProgram(){this._program.bind();}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// SnapInstancingDepthRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");src.push("in vec3 position;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("in float flags;");src.push("in vec4 modelMatrixCol0;");// Modeling matrix
|
|
@@ -17695,7 +17695,7 @@ src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:func
|
|
|
17695
17695
|
// when user first begins interacting with the viewer.
|
|
17696
17696
|
if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapInstancingDepthBufInitRenderer(this._scene,false);}if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapInstancingDepthRenderer(this._scene);}}},{key:"snapDepthBufInitRenderer",get:function get(){if(!this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer=new SnapInstancingDepthBufInitRenderer(this._scene,false);}return this._snapDepthBufInitRenderer;}},{key:"snapDepthRenderer",get:function get(){if(!this._snapDepthRenderer){this._snapDepthRenderer=new SnapInstancingDepthRenderer(this._scene);}return this._snapDepthRenderer;}},{key:"_destroy",value:function _destroy(){if(this._snapDepthBufInitRenderer){this._snapDepthBufInitRenderer.destroy();}if(this._snapDepthRenderer){this._snapDepthRenderer.destroy();}}}]);return SnapInstancingRenderers;}();var cachedRenderers$4={};/**
|
|
17697
17697
|
* @private
|
|
17698
|
-
*/function getSnapInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$4[sceneId];if(!instancingRenderers){instancingRenderers=new SnapInstancingRenderers(scene);cachedRenderers$4[sceneId]=instancingRenderers;instancingRenderers._compile();instancingRenderers.eagerCreateRenders();scene.on("compile",function(){instancingRenderers._compile();instancingRenderers.eagerCreateRenders();});scene.on("destroyed",function(){delete cachedRenderers$4[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempUint8Vec4$2=new Uint8Array(4);var tempFloat32$2=new Float32Array(1);var tempVec4a$b=math.vec4([0,0,0,1]);var tempVec4b$a=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);var tempVec3fa$2=new Float32Array(3);var tempVec3a$m=math.vec3();var tempVec3b$i=math.vec3();var tempVec3c$
|
|
17698
|
+
*/function getSnapInstancingRenderers(scene){var sceneId=scene.id;var instancingRenderers=cachedRenderers$4[sceneId];if(!instancingRenderers){instancingRenderers=new SnapInstancingRenderers(scene);cachedRenderers$4[sceneId]=instancingRenderers;instancingRenderers._compile();instancingRenderers.eagerCreateRenders();scene.on("compile",function(){instancingRenderers._compile();instancingRenderers.eagerCreateRenders();});scene.on("destroyed",function(){delete cachedRenderers$4[sceneId];instancingRenderers._destroy();});}return instancingRenderers;}var tempUint8Vec4$2=new Uint8Array(4);var tempFloat32$2=new Float32Array(1);var tempVec4a$b=math.vec4([0,0,0,1]);var tempVec4b$a=math.vec4([0,0,0,1]);math.vec4([0,0,0,1]);var tempVec3fa$2=new Float32Array(3);var tempVec3a$m=math.vec3();var tempVec3b$i=math.vec3();var tempVec3c$e=math.vec3();var tempVec3d$3=math.vec3();var tempVec3e=math.vec3();var tempVec3f=math.vec3();var tempVec3g=math.vec3();var tempFloat32Vec4$2=new Float32Array(4);/**
|
|
17699
17699
|
* @private
|
|
17700
17700
|
*/var TrianglesInstancingLayer=/*#__PURE__*/function(){/**
|
|
17701
17701
|
* @param cfg
|
|
@@ -17821,7 +17821,7 @@ this._instancingRenderers.occlusionRenderer.drawLayer(frameCtx,this,RENDER_PASSE
|
|
|
17821
17821
|
// } else {
|
|
17822
17822
|
if(this._instancingRenderers.pickNormalsFlatRenderer){this._instancingRenderers.pickNormalsFlatRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}// }
|
|
17823
17823
|
}},{key:"drawSnapInitDepthBuf",value:function drawSnapInitDepthBuf(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._snapInstancingRenderers.snapDepthBufInitRenderer){this._snapInstancingRenderers.snapDepthBufInitRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}},{key:"drawSnapDepths",value:function drawSnapDepths(renderFlags,frameCtx){if(this._numCulledLayerPortions===this._numPortions||this._numVisibleLayerPortions===0){return;}this._updateBackfaceCull(renderFlags,frameCtx);if(this._snapInstancingRenderers.snapDepthRenderer){this._snapInstancingRenderers.snapDepthRenderer.drawLayer(frameCtx,this,RENDER_PASSES.PICK);}}//-----------------------------------------------------------------------------------------
|
|
17824
|
-
},{key:"precisionRayPickSurface",value:function precisionRayPickSurface(portionId,worldRayOrigin,worldRayDir,worldSurfacePos,worldNormal){if(!this.model.scene.pickSurfacePrecisionEnabled){return false;}var geometry=this._state.geometry;var state=this._state;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return false;}if(!portion.inverseMatrix){portion.inverseMatrix=math.inverseMat4(portion.matrix,math.mat4());}if(worldNormal&&!portion.normalMatrix){portion.normalMatrix=math.transposeMat4(portion.inverseMatrix,math.mat4());}var quantizedPositions=geometry.quantizedPositions;var indices=geometry.indices;var origin=state.origin;var offset=portion.offset;var rtcRayOrigin=tempVec3a$m;var rtcRayDir=tempVec3b$i;rtcRayOrigin.set(origin?math.subVec3(worldRayOrigin,origin,tempVec3c$
|
|
17824
|
+
},{key:"precisionRayPickSurface",value:function precisionRayPickSurface(portionId,worldRayOrigin,worldRayDir,worldSurfacePos,worldNormal){if(!this.model.scene.pickSurfacePrecisionEnabled){return false;}var geometry=this._state.geometry;var state=this._state;var portion=this._portions[portionId];if(!portion){this.model.error("portion not found: "+portionId);return false;}if(!portion.inverseMatrix){portion.inverseMatrix=math.inverseMat4(portion.matrix,math.mat4());}if(worldNormal&&!portion.normalMatrix){portion.normalMatrix=math.transposeMat4(portion.inverseMatrix,math.mat4());}var quantizedPositions=geometry.quantizedPositions;var indices=geometry.indices;var origin=state.origin;var offset=portion.offset;var rtcRayOrigin=tempVec3a$m;var rtcRayDir=tempVec3b$i;rtcRayOrigin.set(origin?math.subVec3(worldRayOrigin,origin,tempVec3c$e):worldRayOrigin);// World -> RTC
|
|
17825
17825
|
rtcRayDir.set(worldRayDir);if(offset){math.subVec3(rtcRayOrigin,offset);}math.transformRay(this.model.worldNormalMatrix,rtcRayOrigin,rtcRayDir,rtcRayOrigin,rtcRayDir);math.transformRay(portion.inverseMatrix,rtcRayOrigin,rtcRayDir,rtcRayOrigin,rtcRayDir);var a=tempVec3d$3;var b=tempVec3e;var c=tempVec3f;var gotIntersect=false;var closestDist=0;var closestIntersectPos=tempVec3g;for(var _i261=0,len=indices.length;_i261<len;_i261+=3){var ia=indices[_i261+0]*3;var ib=indices[_i261+1]*3;var ic=indices[_i261+2]*3;a[0]=quantizedPositions[ia];a[1]=quantizedPositions[ia+1];a[2]=quantizedPositions[ia+2];b[0]=quantizedPositions[ib];b[1]=quantizedPositions[ib+1];b[2]=quantizedPositions[ib+2];c[0]=quantizedPositions[ic];c[1]=quantizedPositions[ic+1];c[2]=quantizedPositions[ic+2];var positionsDecodeMatrix=state.geometry.positionsDecodeMatrix;math.decompressPosition(a,positionsDecodeMatrix);math.decompressPosition(b,positionsDecodeMatrix);math.decompressPosition(c,positionsDecodeMatrix);if(math.rayTriangleIntersect(rtcRayOrigin,rtcRayDir,a,b,c,closestIntersectPos)){math.transformPoint3(portion.matrix,closestIntersectPos,closestIntersectPos);math.transformPoint3(this.model.worldMatrix,closestIntersectPos,closestIntersectPos);if(offset){math.addVec3(closestIntersectPos,offset);}if(origin){math.addVec3(closestIntersectPos,origin);}var dist=Math.abs(math.lenVec3(math.subVec3(closestIntersectPos,worldRayOrigin,[])));if(!gotIntersect||dist>closestDist){closestDist=dist;worldSurfacePos.set(closestIntersectPos);if(worldNormal){// Not that wasteful to eagerly compute - unlikely to hit >2 surfaces on most geometry
|
|
17826
17826
|
math.triangleNormal(a,b,c,worldNormal);}gotIntersect=true;}}}if(gotIntersect&&worldNormal){math.transformVec3(portion.normalMatrix,worldNormal,worldNormal);math.transformVec3(this.model.worldNormalMatrix,worldNormal,worldNormal);math.normalizeVec3(worldNormal);}return gotIntersect;}},{key:"destroy",value:function destroy(){var state=this._state;if(state.colorsBuf){state.colorsBuf.destroy();state.colorsBuf=null;}if(state.metallicRoughnessBuf){state.metallicRoughnessBuf.destroy();state.metallicRoughnessBuf=null;}if(state.flagsBuf){state.flagsBuf.destroy();state.flagsBuf=null;}if(state.offsetsBuf){state.offsetsBuf.destroy();state.offsetsBuf=null;}if(state.modelMatrixCol0Buf){state.modelMatrixCol0Buf.destroy();state.modelMatrixCol0Buf=null;}if(state.modelMatrixCol1Buf){state.modelMatrixCol1Buf.destroy();state.modelMatrixCol1Buf=null;}if(state.modelMatrixCol2Buf){state.modelMatrixCol2Buf.destroy();state.modelMatrixCol2Buf=null;}if(state.modelNormalMatrixCol0Buf){state.modelNormalMatrixCol0Buf.destroy();state.modelNormalMatrixCol0Buf=null;}if(state.modelNormalMatrixCol1Buf){state.modelNormalMatrixCol1Buf.destroy();state.modelNormalMatrixCol1Buf=null;}if(state.modelNormalMatrixCol2Buf){state.modelNormalMatrixCol2Buf.destroy();state.modelNormalMatrixCol2Buf=null;}if(state.pickColorsBuf){state.pickColorsBuf.destroy();state.pickColorsBuf=null;}state.destroy();this._state=null;}}]);return TrianglesInstancingLayer;}();/**
|
|
17827
17827
|
* @private
|
|
@@ -18579,9 +18579,9 @@ var edgeIndex=void 0;if((edgeIndex=edgeSearch(ii0,ii1))>=0){if(alreadyOutputEdge
|
|
|
18579
18579
|
// // throw "Ohhhh2!";
|
|
18580
18580
|
// }
|
|
18581
18581
|
// }
|
|
18582
|
-
}}var tempVec3a$k=math.vec3();var tempVec3b$g=math.vec3();var tempVec3c$
|
|
18582
|
+
}}var tempVec3a$k=math.vec3();var tempVec3b$g=math.vec3();var tempVec3c$d=math.vec3();math.vec3();var tempVec4a$6=math.vec4();var tempMat4a$c=math.mat4();/**
|
|
18583
18583
|
* @private
|
|
18584
|
-
*/var TrianglesDataTextureColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureColorRenderer(scene,withSAO){_classCallCheck(this,TrianglesDataTextureColorRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$k;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$g);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(camera.viewMatrix,rtcOrigin,tempMat4a$c);rtcCameraEye=tempVec3c$
|
|
18584
|
+
*/var TrianglesDataTextureColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureColorRenderer(scene,withSAO){_classCallCheck(this,TrianglesDataTextureColorRenderer);this._scene=scene;this._withSAO=withSAO;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){var scene=this._scene;return[scene._lightsState.getHash(),scene._sectionPlanesState.getHash(),this._withSAO?"sao":"nosao"].join(";");}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$k;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$g);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(camera.viewMatrix,rtcOrigin,tempMat4a$c);rtcCameraEye=tempVec3c$d;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=camera.viewMatrix;rtcCameraEye=camera.eye;}gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$k);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
|
|
18585
18585
|
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
|
|
18586
18586
|
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
|
|
18587
18587
|
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;var lightsState=scene._lightsState;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;console.error(this.errors);return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uLightAmbient=program.getLocation("lightAmbient");this._uLightColor=[];this._uLightDir=[];this._uLightPos=[];this._uLightAttenuation=[];var lights=lightsState.lights;var light;for(var _i334=0,len=lights.length;_i334<len;_i334++){light=lights[_i334];switch(light.type){case"dir":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=null;this._uLightDir[_i334]=program.getLocation("lightDir"+_i334);break;case"point":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=program.getLocation("lightPos"+_i334);this._uLightDir[_i334]=null;this._uLightAttenuation[_i334]=program.getLocation("lightAttenuation"+_i334);break;case"spot":this._uLightColor[_i334]=program.getLocation("lightColor"+_i334);this._uLightPos[_i334]=program.getLocation("lightPos"+_i334);this._uLightDir[_i334]=program.getLocation("lightDir"+_i334);this._uLightAttenuation[_i334]=program.getLocation("lightAttenuation"+_i334);break;}}this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i335=0,_len83=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i335<_len83;_i335++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i335),pos:program.getLocation("sectionPlanePos"+_i335),dir:program.getLocation("sectionPlaneDir"+_i335)});}if(this._withSAO){this._uOcclusionTexture="uOcclusionTexture";this._uSAOParams=program.getLocation("uSAOParams");}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var program=this._program;var lights=scene._lightsState.lights;var project=scene.camera.project;program.bind();if(this._uLightAmbient){gl.uniform4fv(this._uLightAmbient,scene._lightsState.getAmbientColorAndIntensity());}for(var _i336=0,len=lights.length;_i336<len;_i336++){var light=lights[_i336];if(this._uLightColor[_i336]){gl.uniform4f(this._uLightColor[_i336],light.color[0],light.color[1],light.color[2],light.intensity);}if(this._uLightPos[_i336]){gl.uniform3fv(this._uLightPos[_i336],light.pos);if(this._uLightAttenuation[_i336]){gl.uniform1f(this._uLightAttenuation[_i336],light.attenuation);}}if(this._uLightDir[_i336]){gl.uniform3fv(this._uLightDir[_i336],light.dir);}}if(this._withSAO){var sao=scene.sao;var saoEnabled=sao.possible;if(saoEnabled){var viewportWidth=gl.drawingBufferWidth;var viewportHeight=gl.drawingBufferHeight;tempVec4a$6[0]=viewportWidth;tempVec4a$6[1]=viewportHeight;tempVec4a$6[2]=sao.blendCutoff;tempVec4a$6[3]=sao.blendFactor;gl.uniform4fv(this._uSAOParams,tempVec4a$6);this._program.bindTexture(this._uOcclusionTexture,frameCtx.occlusionTexture,10);}}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var lightsState=scene._lightsState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var light;var src=[];src.push("#version 300 es");src.push("// TrianglesDataTextureColorRenderer vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");src.push("uniform mat4 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");src.push("uniform highp sampler2D uObjectPerObjectPositionsDecodeMatrix;");src.push("uniform highp sampler2D uTexturePerObjectMatrix;");src.push("uniform lowp usampler2D uObjectPerObjectColorsAndFlags;");src.push("uniform mediump usampler2D uTexturePerVertexIdCoordinates;");src.push("uniform highp usampler2D uTexturePerPolygonIdIndices;");src.push("uniform mediump usampler2D uTexturePerPolygonIdPortionIds;");src.push("uniform vec3 uCameraEyeRtc;");src.push("vec3 positions[3];");if(scene.logarithmicDepthBufferEnabled){src.push("uniform float logDepthBufFC;");src.push("out float vFragDepth;");src.push("out float isPerspective;");}src.push("bool isPerspectiveMatrix(mat4 m) {");src.push(" return (m[2][3] == - 1.0);");src.push("}");src.push("uniform vec4 lightAmbient;");for(var _i337=0,len=lightsState.lights.length;_i337<len;_i337++){light=lightsState.lights[_i337];if(light.type==="ambient"){continue;}src.push("uniform vec4 lightColor"+_i337+";");if(light.type==="dir"){src.push("uniform vec3 lightDir"+_i337+";");}if(light.type==="point"){src.push("uniform vec3 lightPos"+_i337+";");}if(light.type==="spot"){src.push("uniform vec3 lightPos"+_i337+";");src.push("uniform vec3 lightDir"+_i337+";");}}if(clipping){src.push("out vec4 vWorldPosition;");src.push("flat out uint vFlags2;");}src.push("out vec4 vColor;");src.push("void main(void) {");// constants
|
|
@@ -18598,9 +18598,9 @@ src.push("if (dot(position.xyz - uCameraEyeRtcInQuantizedSpace, normal) < 0.0) {
|
|
|
18598
18598
|
src.push("if (viewNormal.z < 0.0) {");src.push("position = positions[2 - (gl_VertexID % 3)];");src.push("viewNormal = -viewNormal;");src.push("}");src.push("}");src.push("}");src.push("vec4 worldPosition = sceneModelMatrix * ((objectDecodeAndInstanceMatrix * vec4(position, 1.0))); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");src.push("vec3 reflectedColor = vec3(0.0, 0.0, 0.0);");src.push("vec3 viewLightDir = vec3(0.0, 0.0, -1.0);");src.push("float lambertian = 1.0;");for(var _i338=0,_len84=lightsState.lights.length;_i338<_len84;_i338++){light=lightsState.lights[_i338];if(light.type==="ambient"){continue;}if(light.type==="dir"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i338+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i338+", 0.0)).xyz);");}}else if(light.type==="point"){if(light.space==="view"){src.push("viewLightDir = -normalize(lightPos"+_i338+" - viewPosition.xyz);");}else{src.push("viewLightDir = -normalize((viewMatrix * vec4(lightPos"+_i338+", 0.0)).xyz);");}}else if(light.type==="spot"){if(light.space==="view"){src.push("viewLightDir = normalize(lightDir"+_i338+");");}else{src.push("viewLightDir = normalize((viewMatrix * vec4(lightDir"+_i338+", 0.0)).xyz);");}}else{continue;}src.push("lambertian = max(dot(-viewNormal, viewLightDir), 0.0);");src.push("reflectedColor += lambertian * (lightColor"+_i338+".rgb * lightColor"+_i338+".a);");}src.push("vec3 rgb = vec3(color.rgb) / 255.0;");src.push("vColor = vec4((lightAmbient.rgb * lightAmbient.a * rgb) + (reflectedColor * rgb), float(color.a) / 255.0);");src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}if(clipping){src.push("vWorldPosition = worldPosition;");src.push("vFlags2 = flags2.r;");}src.push("gl_Position = clipPos;");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var sectionPlanesState=scene._sectionPlanesState;var clipping=sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// TrianglesDataTextureColorRenderer fragment shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(this._withSAO){src.push("uniform sampler2D uOcclusionTexture;");src.push("uniform vec4 uSAOParams;");src.push("const float packUpscale = 256. / 255.;");src.push("const float unpackDownScale = 255. / 256.;");src.push("const vec3 packFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );");src.push("const vec4 unPackFactors = unpackDownScale / vec4( packFactors, 1. );");src.push("float unpackRGBToFloat( const in vec4 v ) {");src.push(" return dot( v, unPackFactors );");src.push("}");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i339=0,len=sectionPlanesState.getNumAllocatedSectionPlanes();_i339<len;_i339++){src.push("uniform bool sectionPlaneActive"+_i339+";");src.push("uniform vec3 sectionPlanePos"+_i339+";");src.push("uniform vec3 sectionPlaneDir"+_i339+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i340=0,_len85=sectionPlanesState.getNumAllocatedSectionPlanes();_i340<_len85;_i340++){src.push("if (sectionPlaneActive"+_i340+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i340+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i340+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { ");src.push(" discard;");src.push(" }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");//src.push(" gl_FragDepth = log2( vFragDepth ) * logDepthBufFC * 0.5;");
|
|
18599
18599
|
}if(this._withSAO){// Doing SAO blend in the main solid fill draw shader just so that edge lines can be drawn over the top
|
|
18600
18600
|
// Would be more efficient to defer this, then render lines later, using same depth buffer for Z-reject
|
|
18601
|
-
src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");}else{src.push(" outColor = vColor;");}src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureColorRenderer;}();var defaultColor$1=new Float32Array([1,1,1]);var tempVec3a$j=math.vec3();var tempVec3b$f=math.vec3();var tempVec3c$
|
|
18601
|
+
src.push(" float viewportWidth = uSAOParams[0];");src.push(" float viewportHeight = uSAOParams[1];");src.push(" float blendCutoff = uSAOParams[2];");src.push(" float blendFactor = uSAOParams[3];");src.push(" vec2 uv = vec2(gl_FragCoord.x / viewportWidth, gl_FragCoord.y / viewportHeight);");src.push(" float ambient = smoothstep(blendCutoff, 1.0, unpackRGBToFloat(texture(uOcclusionTexture, uv))) * blendFactor;");src.push(" outColor = vec4(vColor.rgb * ambient, 1.0);");}else{src.push(" outColor = vColor;");}src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureColorRenderer;}();var defaultColor$1=new Float32Array([1,1,1]);var tempVec3a$j=math.vec3();var tempVec3b$f=math.vec3();var tempVec3c$c=math.vec3();math.vec3();var tempMat4a$b=math.mat4();/**
|
|
18602
18602
|
* @private
|
|
18603
|
-
*/var TrianglesDataTextureSilhouetteRenderer=/*#__PURE__*/function(){function TrianglesDataTextureSilhouetteRenderer(scene,primitiveType){_classCallCheck(this,TrianglesDataTextureSilhouetteRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureSilhouetteRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3a$j;if(origin){var rotatedOrigin=tempVec3b$f;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$b);rtcCameraEye=tempVec3c$
|
|
18603
|
+
*/var TrianglesDataTextureSilhouetteRenderer=/*#__PURE__*/function(){function TrianglesDataTextureSilhouetteRenderer(scene,primitiveType){_classCallCheck(this,TrianglesDataTextureSilhouetteRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureSilhouetteRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var scene=this._scene;var camera=scene.camera;var model=dataTextureLayer.model;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram(frameCtx,state);}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var rtcCameraEye;if(origin||position[0]!==0||position[1]!==0||position[2]!==0){var rtcOrigin=tempVec3a$j;if(origin){var rotatedOrigin=tempVec3b$f;math.transformPoint3(rotationMatrix,origin,rotatedOrigin);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$b);rtcCameraEye=tempVec3c$c;rtcCameraEye[0]=camera.eye[0]-rtcOrigin[0];rtcCameraEye[1]=camera.eye[1]-rtcOrigin[1];rtcCameraEye[2]=camera.eye[2]-rtcOrigin[2];}else{rtcViewMatrix=viewMatrix;rtcCameraEye=camera.eye;}gl.uniform3fv(this._uCameraEyeRtc,rtcCameraEye);gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uWorldMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);if(renderPass===RENDER_PASSES.SILHOUETTE_XRAYED){var material=scene.xrayMaterial._state;var fillColor=material.fillColor;var fillAlpha=material.fillAlpha;gl.uniform4f(this._uColor,fillColor[0],fillColor[1],fillColor[2],fillAlpha);}else if(renderPass===RENDER_PASSES.SILHOUETTE_HIGHLIGHTED){var _material3=scene.highlightMaterial._state;var _fillColor=_material3.fillColor;var _fillAlpha=_material3.fillAlpha;gl.uniform4f(this._uColor,_fillColor[0],_fillColor[1],_fillColor[2],_fillAlpha);}else if(renderPass===RENDER_PASSES.SILHOUETTE_SELECTED){var _material4=scene.selectedMaterial._state;var _fillColor2=_material4.fillColor;var _fillAlpha2=_material4.fillAlpha;gl.uniform4f(this._uColor,_fillColor2[0],_fillColor2[1],_fillColor2[2],_fillAlpha2);}else{gl.uniform4fv(this._uColor,defaultColor$1);}if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(frameCtx.pickZFar+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$j);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numIndices8Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,8// 8 bits indices
|
|
18604
18604
|
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices8Bits);}if(state.numIndices16Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,16// 16 bits indices
|
|
18605
18605
|
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices16Bits);}if(state.numIndices32Bits>0){textureState.bindTriangleIndicesTextures(this._program,this._uTexturePerPolygonIdPortionIds,this._uTexturePerPolygonIdIndices,32// 32 bits indices
|
|
18606
18606
|
);gl.drawArrays(gl.TRIANGLES,0,state.numIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uColor=program.getLocation("color");this._uWorldMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i341=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i341<len;_i341++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i341),pos:program.getLocation("sectionPlanePos"+_i341),dir:program.getLocation("sectionPlaneDir"+_i341)});}if(scene.logarithmicDepthBufferEnabled){this._uLogDepthBufFC=program.getLocation("logDepthBufFC");}this.uTexturePerObjectPositionsDecodeMatrix="uObjectPerObjectPositionsDecodeMatrix";this.uTexturePerObjectColorsAndFlags="uObjectPerObjectColorsAndFlags";this._uTexturePerVertexIdCoordinates="uTexturePerVertexIdCoordinates";this._uTexturePerPolygonIdNormals="uTexturePerPolygonIdNormals";this._uTexturePerPolygonIdIndices="uTexturePerPolygonIdIndices";this._uTexturePerPolygonIdPortionIds="uTexturePerPolygonIdPortionIds";this._uTexturePerObjectMatrix="uTexturePerObjectMatrix";this._uCameraEyeRtc=program.getLocation("uCameraEyeRtc");}},{key:"_bindProgram",value:function _bindProgram(frameCtx){var scene=this._scene;var gl=scene.canvas.gl;var project=scene.camera.project;this._program.bind();if(scene.logarithmicDepthBufferEnabled){var logDepthBufFC=2.0/(Math.log(project.far+1.0)/Math.LN2);gl.uniform1f(this._uLogDepthBufFC,logDepthBufFC);}}},{key:"_buildShader",value:function _buildShader(){return{vertex:this._buildVertexShader(),fragment:this._buildFragmentShader()};}},{key:"_buildVertexShader",value:function _buildVertexShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push("#version 300 es");src.push("// Triangles dataTexture silhouette vertex shader");src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("precision highp usampler2D;");src.push("precision highp isampler2D;");src.push("precision highp sampler2D;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("precision mediump usampler2D;");src.push("precision mediump isampler2D;");src.push("precision mediump sampler2D;");src.push("#endif");src.push("uniform int renderPass;");if(scene.entityOffsetsEnabled){src.push("in vec3 offset;");}src.push("uniform mat4 sceneModelMatrix;");src.push("uniform mat4 viewMatrix;");src.push("uniform mat4 projMatrix;");// src.push("uniform sampler2D uOcclusionTexture;");
|
|
@@ -18633,9 +18633,9 @@ src.push(" return;");// Cull vertex
|
|
|
18633
18633
|
src.push("} else {");// get vertex base
|
|
18634
18634
|
src.push("ivec4 packedVertexBase = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+4, objectIndexCoords.y), 0));");src.push("ivec4 packedEdgeIndexBaseOffset = ivec4(texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+6, objectIndexCoords.y), 0));");src.push("int edgeIndexBaseOffset = (packedEdgeIndexBaseOffset.r << 24) + (packedEdgeIndexBaseOffset.g << 16) + (packedEdgeIndexBaseOffset.b << 8) + packedEdgeIndexBaseOffset.a;");src.push("int h_index = (edgeIndex - edgeIndexBaseOffset) & 4095;");src.push("int v_index = (edgeIndex - edgeIndexBaseOffset) >> 12;");src.push("ivec3 vertexIndices = ivec3(texelFetch(uTexturePerPolygonIdEdgeIndices, ivec2(h_index, v_index), 0));");src.push("ivec3 uniqueVertexIndexes = vertexIndices + (packedVertexBase.r << 24) + (packedVertexBase.g << 16) + (packedVertexBase.b << 8) + packedVertexBase.a;");src.push("int indexPositionH = uniqueVertexIndexes[gl_VertexID % 2] & 4095;");src.push("int indexPositionV = uniqueVertexIndexes[gl_VertexID % 2] >> 12;");src.push("mat4 objectInstanceMatrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("mat4 objectDecodeAndInstanceMatrix = objectInstanceMatrix * mat4 (texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uObjectPerObjectPositionsDecodeMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");// get flags & flags2
|
|
18635
18635
|
src.push("uvec4 flags = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+2, objectIndexCoords.y), 0);");src.push("uvec4 flags2 = texelFetch (uObjectPerObjectColorsAndFlags, ivec2(objectIndexCoords.x*8+3, objectIndexCoords.y), 0);");// get position
|
|
18636
|
-
src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push("mat4 matrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("vColor = vec4(color.r, color.g, color.b, color.a);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Batched geometry edges drawing fragment shader");if(scene.logarithmicDepthBufferEnabled){src.push("#extension GL_EXT_frag_depth : enable");}src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i345=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i345<len;_i345++){src.push("uniform bool sectionPlaneActive"+_i345+";");src.push("uniform vec3 sectionPlanePos"+_i345+";");src.push("uniform vec3 sectionPlaneDir"+_i345+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i346=0,_len87=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i346<_len87;_i346++){src.push("if (sectionPlaneActive"+_i346+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i346+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i346+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureEdgesRenderer;}();var tempVec3a$h=math.vec3();var tempVec3b$d=math.vec3();
|
|
18636
|
+
src.push("vec3 position = vec3(texelFetch(uTexturePerVertexIdCoordinates, ivec2(indexPositionH, indexPositionV), 0));");src.push("mat4 matrix = mat4 (texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+0, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+1, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+2, objectIndexCoords.y), 0), texelFetch (uTexturePerObjectMatrix, ivec2(objectIndexCoords.x*4+3, objectIndexCoords.y), 0));");src.push("vec4 worldPosition = sceneModelMatrix * (objectDecodeAndInstanceMatrix * vec4(position, 1.0)); ");src.push("vec4 viewPosition = viewMatrix * worldPosition; ");if(clipping){src.push(" vWorldPosition = worldPosition;");src.push(" vFlags2 = flags2.r;");}src.push("vec4 clipPos = projMatrix * viewPosition;");if(scene.logarithmicDepthBufferEnabled){src.push("vFragDepth = 1.0 + clipPos.w;");src.push("isPerspective = float (isPerspectiveMatrix(projMatrix));");}src.push("gl_Position = clipPos;");src.push("vColor = vec4(color.r, color.g, color.b, color.a);");src.push("}");src.push("}");return src;}},{key:"_buildFragmentShader",value:function _buildFragmentShader(){var scene=this._scene;var clipping=scene._sectionPlanesState.getNumAllocatedSectionPlanes()>0;var src=[];src.push('#version 300 es');src.push("// Batched geometry edges drawing fragment shader");if(scene.logarithmicDepthBufferEnabled){src.push("#extension GL_EXT_frag_depth : enable");}src.push("#ifdef GL_FRAGMENT_PRECISION_HIGH");src.push("precision highp float;");src.push("precision highp int;");src.push("#else");src.push("precision mediump float;");src.push("precision mediump int;");src.push("#endif");if(scene.logarithmicDepthBufferEnabled){src.push("in float isPerspective;");src.push("uniform float logDepthBufFC;");src.push("in float vFragDepth;");}if(clipping){src.push("in vec4 vWorldPosition;");src.push("flat in uint vFlags2;");for(var _i345=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i345<len;_i345++){src.push("uniform bool sectionPlaneActive"+_i345+";");src.push("uniform vec3 sectionPlanePos"+_i345+";");src.push("uniform vec3 sectionPlaneDir"+_i345+";");}}src.push("in vec4 vColor;");src.push("out vec4 outColor;");src.push("void main(void) {");if(clipping){src.push(" bool clippable = vFlags2 > 0u;");src.push(" if (clippable) {");src.push(" float dist = 0.0;");for(var _i346=0,_len87=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i346<_len87;_i346++){src.push("if (sectionPlaneActive"+_i346+") {");src.push(" dist += clamp(dot(-sectionPlaneDir"+_i346+".xyz, vWorldPosition.xyz - sectionPlanePos"+_i346+".xyz), 0.0, 1000.0);");src.push("}");}src.push(" if (dist > 0.0) { discard; }");src.push("}");}if(scene.logarithmicDepthBufferEnabled){src.push(" gl_FragDepth = isPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;");}src.push(" outColor = vColor;");src.push("}");return src;}},{key:"webglContextRestored",value:function webglContextRestored(){this._program=null;}},{key:"destroy",value:function destroy(){if(this._program){this._program.destroy();}this._program=null;}}]);return TrianglesDataTextureEdgesRenderer;}();var tempVec3a$h=math.vec3();var tempVec3b$d=math.vec3();math.vec3();var tempMat4a$9=math.mat4();/**
|
|
18637
18637
|
* @private
|
|
18638
|
-
*/var TrianglesDataTextureEdgesColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureEdgesColorRenderer(scene){_classCallCheck(this,TrianglesDataTextureEdgesColorRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureEdgesColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$h;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$d);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$9);}else{rtcViewMatrix=viewMatrix;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);var
|
|
18638
|
+
*/var TrianglesDataTextureEdgesColorRenderer=/*#__PURE__*/function(){function TrianglesDataTextureEdgesColorRenderer(scene){_classCallCheck(this,TrianglesDataTextureEdgesColorRenderer);this._scene=scene;this._hash=this._getHash();this._allocate();}_createClass(TrianglesDataTextureEdgesColorRenderer,[{key:"getValid",value:function getValid(){return this._hash===this._getHash();}},{key:"_getHash",value:function _getHash(){return this._scene._sectionPlanesState.getHash();}},{key:"drawLayer",value:function drawLayer(frameCtx,dataTextureLayer,renderPass){var model=dataTextureLayer.model;var scene=model.scene;var camera=scene.camera;var gl=scene.canvas.gl;var state=dataTextureLayer._state;var textureState=state.textureState;var origin=dataTextureLayer._state.origin;var position=model.position,rotationMatrix=model.rotationMatrix,rotationMatrixConjugate=model.rotationMatrixConjugate;var viewMatrix=camera.viewMatrix;if(!this._program){this._allocate();if(this.errors){return;}}if(frameCtx.lastProgramId!==this._program.id){frameCtx.lastProgramId=this._program.id;this._bindProgram();}textureState.bindCommonTextures(this._program,this.uTexturePerObjectPositionsDecodeMatrix,this._uTexturePerVertexIdCoordinates,this.uTexturePerObjectColorsAndFlags,this._uTexturePerObjectMatrix);var rtcViewMatrix;var gotOrigin=origin[0]!==0||origin[1]!==0||origin[2]!==0;var gotPosition=position[0]!==0||position[1]!==0||position[2]!==0;if(gotOrigin||gotPosition){var rtcOrigin=tempVec3a$h;if(gotOrigin){var rotatedOrigin=math.transformPoint3(rotationMatrix,origin,tempVec3b$d);rtcOrigin[0]=rotatedOrigin[0];rtcOrigin[1]=rotatedOrigin[1];rtcOrigin[2]=rotatedOrigin[2];}else{rtcOrigin[0]=0;rtcOrigin[1]=0;rtcOrigin[2]=0;}rtcOrigin[0]+=position[0];rtcOrigin[1]+=position[1];rtcOrigin[2]+=position[2];rtcViewMatrix=createRTCViewMat(viewMatrix,rtcOrigin,tempMat4a$9);}else{rtcViewMatrix=viewMatrix;}gl.uniform1i(this._uRenderPass,renderPass);gl.uniformMatrix4fv(this._uSceneModelMatrix,false,rotationMatrixConjugate);gl.uniformMatrix4fv(this._uViewMatrix,false,rtcViewMatrix);gl.uniformMatrix4fv(this._uProjMatrix,false,camera.projMatrix);var numAllocatedSectionPlanes=scene._sectionPlanesState.getNumAllocatedSectionPlanes();var numSectionPlanes=scene._sectionPlanesState.sectionPlanes.length;if(numAllocatedSectionPlanes>0){var sectionPlanes=scene._sectionPlanesState.sectionPlanes;var baseIndex=dataTextureLayer.layerIndex*numSectionPlanes;var renderFlags=model.renderFlags;for(var sectionPlaneIndex=0;sectionPlaneIndex<numAllocatedSectionPlanes;sectionPlaneIndex++){var sectionPlaneUniforms=this._uSectionPlanes[sectionPlaneIndex];if(sectionPlaneUniforms){if(sectionPlaneIndex<numSectionPlanes){var active=renderFlags.sectionPlanesActivePerLayer[baseIndex+sectionPlaneIndex];gl.uniform1i(sectionPlaneUniforms.active,active?1:0);if(active){var sectionPlane=sectionPlanes[sectionPlaneIndex];if(origin){var rtcSectionPlanePos=getPlaneRTCPos(sectionPlane.dist,sectionPlane.dir,origin,tempVec3a$h);gl.uniform3fv(sectionPlaneUniforms.pos,rtcSectionPlanePos);}else{gl.uniform3fv(sectionPlaneUniforms.pos,sectionPlane.pos);}gl.uniform3fv(sectionPlaneUniforms.dir,sectionPlane.dir);}}else{gl.uniform1i(sectionPlaneUniforms.active,0);}}}}if(state.numEdgeIndices8Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,8// 8 bits edge indices
|
|
18639
18639
|
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices8Bits);}if(state.numEdgeIndices16Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,16// 16 bits edge indices
|
|
18640
18640
|
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices16Bits);}if(state.numEdgeIndices32Bits>0){textureState.bindEdgeIndicesTextures(this._program,this._uTexturePerEdgeIdPortionIds,this._uTexturePerPolygonIdEdgeIndices,32// 32 bits edge indices
|
|
18641
18641
|
);gl.drawArrays(gl.LINES,0,state.numEdgeIndices32Bits);}frameCtx.drawElements++;}},{key:"_allocate",value:function _allocate(){var scene=this._scene;var gl=scene.canvas.gl;this._program=new Program(gl,this._buildShader());if(this._program.errors){this.errors=this._program.errors;return;}var program=this._program;this._uRenderPass=program.getLocation("renderPass");this._uSceneModelMatrix=program.getLocation("sceneModelMatrix");this._uViewMatrix=program.getLocation("viewMatrix");this._uProjMatrix=program.getLocation("projMatrix");this._uSectionPlanes=[];for(var _i347=0,len=scene._sectionPlanesState.getNumAllocatedSectionPlanes();_i347<len;_i347++){this._uSectionPlanes.push({active:program.getLocation("sectionPlaneActive"+_i347),pos:program.getLocation("sectionPlanePos"+_i347),dir:program.getLocation("sectionPlaneDir"+_i347)});}//this._aOffset = program.getAttribute("offset");
|