mx3d 0.0.15 → 0.0.19
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/core/mx3d.dazzle.min.js +3 -3
- package/mx3d.js +3014 -3014
- package/mx3d.min.js +3 -3
- package/package.json +1 -1
package/core/mx3d.dazzle.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("h337")):"function"==typeof define&&define.amd?define(["h337"],t):"object"==typeof exports?exports.Dazzle=t(require("h337")):e.Dazzle=t(e.h337)}(window,function(i){return n=[function(e,t){e.exports=i},function(e,t,i){"use strict";i.r(t);var n={};i.r(n),i.d(n,"SceneLoader",function(){return h}),i.d(n,"Global",function(){return o}),i.d(n,"Builder",function(){return s}),i.d(n,"IconFromMesh",function(){return l}),i.d(n,"Icon",function(){return a}),i.d(n,"GUID",function(){return r}),i.d(n,"HeatMap",function(){return u}),i.d(n,"Capacity",function(){return c});class r{static getGUID(e){var t,i,n="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),s=[],o=n.length;if(e)for(t=0;t<e;t++)s[t]=n[0|Math.random()*o];else for(s[8]=s[13]=s[18]=s[23]="-",s[14]="4",t=0;t<36;t++)s[t]||(i=0|16*Math.random(),s[t]=n[19==t?3&i|8:i]);return s.join("")}}class u{constructor(e){this.anchor=e,this.id=r.getGUID(12),this.texts=new Array}isEnabled(e){}set displayValues(t){this.texts.forEach(e=>e.isVisible=t)}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose();for(let e=0;e<this.texts.length;e++)this.texts[e].linkedMesh&&this.texts[e].linkedMesh.dispose(),this.texts[e].dispose();this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}var m=i(0);class c{constructor(e,t){this.anchor=e,this.ratio=t}dispose(){this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.mesh&&this.mesh.dispose(),this.textMesh&&this.textMesh.dispose(),this.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class s{static createMatrixHeatMap(s){s.displayValues=null==s.displayValues||s.displayValues,s.isAlpha=null==s.isAlpha||s.isAlpha,s.isParticle=null==s.isParticle||s.isParticle,s.height=s.height||.5,s.radius=s.radius||2.8,s.isLevelRender=null==s.isLevelRender||s.isLevelRender,s.range=s.range||{max:30,min:16};let o;if(!(s.config||s.config.maxX||s.config.maxY||s.config.data||s.anchor))return o;s.anchor._scene.blockfreeActiveMeshesAndRenderingGroups=!0,o=new u(s.anchor.id);var r=s.anchor.getBoundingInfo();o.mesh=s.anchor.clone(o.id),o.mesh.position.y+=s.height;var a=r.maximum.x-r.minimum.x,c=a/(2*s.config.maxX),l=r.maximum.z-r.minimum.z,h=l/(2*s.config.maxY);let e=new Array;for(let n=0;n<2*s.config.maxX;n++)for(let i=0;i<2*s.config.maxY;i++){let t={x:n,y:i,value:s.range.min};for(let e=0;e<s.config.data.length;e++){var d=s.config.data[e];2*d.x+1==n&&2*d.y+1==i&&(t.value=d.value,d=new BABYLON.Vector3(r.boundingSphere.center.x-(a/2-c*n),o.mesh.position.y,r.boundingSphere.center.z-(l/2-h*i)),o.texts.push(this.createTempVlaue(t.value+"℃",d,s.anchor._scene,s.container)))}e.push(t)}o.displayValues=s.displayValues;let t=m.create({width:2*s.config.maxX,height:2*s.config.maxY,radius:s.radius});t.setData({min:s.range.min,max:s.range.max,data:e});let i=new BABYLON.StandardMaterial(o.id,s.anchor._scene);return i.diffuseTexture=new BABYLON.Texture(t.getDataURL(),s.anchor._scene,!1,!1),i.specularColor=new BABYLON.Color3(0,0,0),i.alpha=.5,s.isAlpha&&(i.diffuseTexture.hasAlpha=!0),s.isParticle&&(this._getMatrixParticleTex(s.rootUrl,s.FogTex,i.diffuseTexture,o.mesh,s.anchor._scene,s.isLevelRender),o.mesh.isVisible=!1),s.isLevelRender&&(o.mesh.renderingGroupId=1),o.mesh.material=i,o.mesh.alwaysSelectAsActiveMesh=!0,o.mesh.freezeWorldMatrix(),s.anchor._scene.blockfreeActiveMeshesAndRenderingGroups=!1,o}static _getMatrixParticleTex(e,t,i,n,s,o){let r;let a=t.clone(),c=n.getBoundingInfo().boundingBox;var l=(c.extendSizeWorld.x+c.extendSizeWorld.z)/9,h=1500*l*l,d=c.minimumWorld.subtract(new BABYLON.Vector3(-0,0,-0)),t=c.maximumWorld.subtract(new BABYLON.Vector3(0,0,0));r&&r.dispose(),r=new BABYLON.ParticleSystem("particles",h,s),r.manualEmitCount=r.getCapacity(),r.minEmitBox=d,r.maxEmitBox=t,r.particleTexture=a,r.emitter=n,o&&(r.renderingGroupId=1),r.isLocal=!0;let u=new BABYLON.NodeMaterial("nm_heatmapBox_"+n.id,s);u.loadAsync(e+"resources/horizontalNodeMat.json").then(()=>{u.build(!1),u.getBlockByName("boxTex").texture=i,u.getBlockByName("emitXMin").value=r.minEmitBox.x,u.getBlockByName("emitXMax").value=r.maxEmitBox.x,u.getBlockByName("emitYMin").value=r.minEmitBox.z,u.getBlockByName("emitYMax").value=r.maxEmitBox.z,u.createEffectForParticles(r)}),n.onDispose=()=>{r&&r.dispose()},r.onDispose=()=>{u&&u.dispose(),a&&a.dispose()},r.color1=new BABYLON.Color4(.8,.8,.8,.1),r.color2=new BABYLON.Color4(.95,.95,.95,.15),r.colorDead=new BABYLON.Color4(.9,.9,.9,.1),r.minSize=1.4,r.maxSize=2,r.minLifeTime=Number.MAX_SAFE_INTEGER,r.emitRate=5e4*l,r.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,r.gravity=new BABYLON.Vector3(0,0,0),r.direction1=new BABYLON.Vector3(0,0,0),r.direction2=new BABYLON.Vector3(0,0,0),r.minAngularSpeed=-2,r.maxAngularSpeed=2,r.minEmitPower=.5,r.maxEmitPower=1,r.updateSpeed=.005,r.start()}static createColumnarHeatMap(s){if(s.displayValues=null==s.displayValues||s.displayValues,s.isAlpha=null==s.isAlpha||s.isAlpha,s.isParticle=null==s.isParticle||s.isParticle,s.radius=s.radius||4,s.isLevelRender=null==s.isLevelRender||s.isLevelRender,s.range=s.range||{max:30,min:16},!s.config&&s.config.length<1&&!s.anchor)return null;let t;s.anchor._scene.blockfreeActiveMeshesAndRenderingGroups=!0,t=new u(s.anchor.id),t.scene=s.anchor._scene;var i=.98*s.anchor.scaling.y;t.mesh=BABYLON.MeshBuilder.CreatePlane(t.id,{width:.98*s.anchor.scaling.x,height:i,sideOrientation:2},s.anchor._scene),t.mesh.alwaysSelectAsActiveMesh=!0,t.mesh.enablePointerMoveEvents=!1,t.mesh.position=s.anchor.position.clone(),t.mesh.rotation.z=Math.PI,t.mesh.rotation.y=s.anchor.rotation.y,s.isLevelRender&&(t.mesh.renderingGroupId=1);let e=[];for(let n=0;n<4;n++)for(let i=0;i<3*s.config.length;i++){let t={x:n,y:i,value:s.range.min};for(let e=0;e<s.config.length;e++){var o=s.config[e];2==n&&3*e+2==i&&(t.value=o.value)}e.push(t)}var n=i/s.config.length;for(let e=0;e<s.config.length;e++){var r=new BABYLON.Vector3(t.mesh.position.x,i-n*e-n/2,t.mesh.position.z);t.texts.push(this.createTempVlaue(s.config[e].value+"℃",r,s.anchor._scene,s.container))}t.displayValues=s.displayValues;let a=m.create({width:4,height:3*s.config.length,radius:s.radius});a.setData({min:s.range.min,max:s.range.max,data:e});let c=new BABYLON.StandardMaterial(t.id,s.anchor._scene);return c.diffuseTexture=new BABYLON.Texture(a.getDataURL(),s.anchor._scene,!1,!1),c.specularColor=new BABYLON.Color3(0,0,0),c.alpha=.5,s.isAlpha&&(c.diffuseTexture.hasAlpha=!0),s.isParticle&&(this._getColumnarParticleTex(c.diffuseTexture,t.mesh,s.anchor._scene,s.FogTex,s.isLevelRender),t.mesh.isVisible=!1),t.mesh.material=c,s.anchor._scene.blockfreeActiveMeshesAndRenderingGroups=!1,t}static _getColumnarParticleTex(e,t,i,n,s){let o;let r=n.clone();n=t.getBoundingInfo().boundingBox,n.extendSizeWorld.x,n.extendSizeWorld.z;BABYLON.Effect.ShadersStore.particlesVertexShader=`
|
|
2
2
|
precision highp float;
|
|
3
3
|
in vec3 position;
|
|
4
4
|
in vec4 color;
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
vUV=offset;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
`,BABYLON.Effect.ShadersStore[
|
|
44
|
+
`,BABYLON.Effect.ShadersStore[t.id+"myParticleFragmentShader"]=`
|
|
45
45
|
#ifdef GL_ES
|
|
46
46
|
precision highp float;
|
|
47
47
|
#endif
|
|
@@ -82,4 +82,4 @@
|
|
|
82
82
|
|
|
83
83
|
gl_FragColor = vec4(baseTex.xyz, resAlpha.a);
|
|
84
84
|
}
|
|
85
|
-
`;var a=
|
|
85
|
+
`;var a=i.getEngine().createEffectForParticles(t.id+"myParticle",["time","u_emitXMin","u_emitYMin","u_emitXMax","u_emitYMax","emitBox_WorldM"],["boxTexSampler"],"");return t.onAfterWorldMatrixUpdateObservable.add(()=>{a.setMatrix("emitBox_WorldM",t.getWorldMatrix())}),a.onCompileObservable.add(()=>{a.setMatrix("emitBox_WorldM",t.getWorldMatrix()),a.setFloat("u_emitXMin",o.minEmitBox.x),a.setFloat("u_emitYMin",o.minEmitBox.y),a.setFloat("u_emitXMax",o.maxEmitBox.x),a.setFloat("u_emitYMax",o.maxEmitBox.y)}),a.onBind=function(){a.setTexture("boxTexSampler",e)},o&&o.dispose(),o=new BABYLON.ParticleSystem("particles",200,i,a),o.manualEmitCount=o.getCapacity(),o.minEmitBox=n.minimum,o.maxEmitBox=n.maximum,t.onDispose=()=>{o&&o.dispose()},o.onDispose=()=>{r&&r.dispose()},o.particleTexture=r.clone(),o.emitter=t,s&&(o.renderingGroupId=1),o.isLocal=!0,o.color1=new BABYLON.Color4(.8,.8,.8,.1),o.color2=new BABYLON.Color4(.95,.95,.95,.15),o.colorDead=new BABYLON.Color4(.9,.9,.9,.1),o.minSize=.7,o.maxSize=1,o.minLifeTime=Number.MAX_SAFE_INTEGER,o.emitRate=50,o.blendMode=BABYLON.ParticleSystem.BLENDMODE_STANDARD,o.gravity=new BABYLON.Vector3(0,0,0),o.direction1=new BABYLON.Vector3(0,0,0),o.direction2=new BABYLON.Vector3(0,0,0),o.minAngularSpeed=-2,o.maxAngularSpeed=2,o.minEmitPower=.5,o.maxEmitPower=1,o.updateSpeed=.005,o.start(),o}static createTempVlaue(e,t,i,n){let s=new BABYLON.Mesh("temp_"+r.getGUID(12),i);s.position=t;let o=new BABYLON.GUI.TextBlock;return o.isPointerBlocker=!1,o.text="默认提示",o.color="white",o.resizeToFit=!0,o.fontSize="20px",o.text=e,n.addControl(o),o.linkWithMesh(s),o}static createCapacity(e,t,i,n="200px"){let s=new c(e,t);s.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0,s.mesh=BABYLON.MeshBuilder.CreateBox("RATIO_"+s.anchor.id,{size:1}),s.mesh.position=s.anchor.instance.position.clone(),s.mesh.position.y-=s.mesh.scaling.y/2,s.mesh.scaling=s.anchor.instance.scaling.clone(),s.mesh.scaling.x=.98*s.mesh.scaling.x,s.mesh.scaling.z=.98*s.mesh.scaling.z,s.mesh.rotation=s.anchor.instance.rotation.clone(),s.mesh.alwaysSelectAsActiveMesh=!0,s.mesh.visibility=1;let o=t<.25?BABYLON.Color3.Blue():.25<=t&&t<.5?BABYLON.Color3.Green():.5<=t&&t<.75?BABYLON.Color3.Yellow():BABYLON.Color3.Red();s.color=o.toHexString(),t*=s.mesh.scaling.y;var r=new BABYLON.Vector3(0,-.5,0);s.mesh.setPivotPoint(r);let a=new BABYLON.StandardMaterial(s.mesh.id,s.anchor.instance._scene);return a.diffuseColor=o,s.mesh.material=a,BABYLON.Animation.CreateAndStartAnimation(s.mesh.id,s.mesh,"scaling.y",15,30,.02,t,0,null),s.anchor.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,i&&(s.textMesh=this.createTextMesh(e,i,t,n,"#fff")),s}static createTextMesh(e,t,i,n="200px",s="white"){e.app.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let o=BABYLON.Mesh.CreatePlane("text_"+e.id,e.instance.scaling.x,e.app.scene,!0,BABYLON.Mesh.DOUBLESIDE);o.alwaysSelectAsActiveMesh=!0,o.position=e.instance.position.clone(),o.position.y=i+.05,o.rotation.y=Math.PI-e.instance.rotation.y,o.rotation.x=-Math.PI/2;let r=new BABYLON.StandardMaterial("text_mat_"+e.id,e.app.scene);r.diffuseColor=BABYLON.Color3.White(),r.emissiveColor=BABYLON.Color3.White();let a=new BABYLON.DynamicTexture("text_tex_"+e.id,{width:1e3*e.instance.scaling.x,height:500*e.instance.scaling.x},e.app.scene,!1);return a.hasAlpha=!0,r.diffuseTexture=a,r.opacityTexture=a,a.drawText(t,1e3*e.instance.scaling.x/4,500*e.instance.scaling.x/2,"bold "+n+" NexaBold",s,"",!0,!0),a.update(),o.material=r,e.app.scene.blockfreeActiveMeshesAndRenderingGroups=!1,o}}class o{}class a{constructor(e){this.textDics=new Array,this.id=e}set background(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._background&&this._background.dispose(),this._background=new BABYLON.GUI.Image(r.getGUID(12)+"_Image",e),this._background.width=this.size.width+"px",this._background.height=this.size.height+"px",this.rect.addControl(this._background),this.onPointerClick&&(this._background.isPointerBlocker=!1,this._background.onPointerClickObservable.add(()=>{this.onPointerClick()})),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setTexts(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.textDics.forEach(e=>e.dispose());for(let t=this.textDics.length=0;t<i.length;t++){let e=new BABYLON.GUI.TextBlock;e.text=i[t].text,e.fontSize=i[t].fontSize||"20px",e.color=i[t].color||"white",e.top=i[t].top||0,e.left=i[t].left||0,this.rect.addControl(e),this.textDics.push(e)}this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}line(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this._line&&this._line.dispose(),this._line=new BABYLON.GUI.Line,this._line.lineWidth=e.width||1.5,this._line.color=e.color||"green",this._line.y2=this.size.height/2,this.container.addControl(this._line),this._line.linkWithMesh(this.pint),this._line.connectedControl=this.rect,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&this.rect.dispose(),this._line&&this._line.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.rect&&(this.rect.isVisible=e),this._line&&(this._line.isVisible=e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class l{constructor(e,t,i,n,s,o){this.id=e,this.scene=o,this.anchor=t,this.url=i,this.scaling=n,this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance=BABYLON.Mesh.CreatePlane(this.id,n,this.scene,!0,BABYLON.Mesh.DOUBLESIDE),this.instance.alwaysSelectAsActiveMesh=!0,this.instance.position=this.anchor.position.clone();n=this.anchor.getBoundingInfo();this.instance.position.y+=(n.maximum.y-n.minimum.y)/2+s,this.instance.billboardMode=BABYLON.Mesh.BILLBOARDMODE_Y;let r=new BABYLON.StandardMaterial("Mat_"+this.id,this.scene);r.diffuseColor=BABYLON.Color3.White(),r.emissiveColor=BABYLON.Color3.White(),this.instance.material=r,this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setBackground(){let i=new Image;i.src=this.url,i.onload=()=>{this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.scaling.y=this.scaling/(i.width/i.height)/this.scaling;let e=new BABYLON.DynamicTexture(this.id,{width:i.width,height:i.height},this.scene,!1);e.hasAlpha=!0,this.instance.material.diffuseTexture=e;let t=e.getContext();t.drawImage(i,0,0),e.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}setColor(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.material.diffuseColor=BABYLON.Color3.FromHexString(e),this.instance.material.emissiveColor=BABYLON.Color3.FromHexString(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}setContents(i){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0;let n=new Image;n.src=this.url,n.onload=()=>{this.instance.scaling.y=this.scaling/(n.width/n.height)/this.scaling;let t=new BABYLON.DynamicTexture(this.id,{width:n.width,height:n.height},this.scene,!1);t.hasAlpha=!0,this.instance.material.diffuseTexture=t;let e=t.getContext();e.drawImage(n,0,0),i.forEach(e=>t.drawText(e.text,e.left,e.top,"bold "+e.fontSize+" monospace",e.color||"#fffffb","",!0,!0)),t.update(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}dispose(){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.dispose(),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}isEnabled(e){this.scene.blockfreeActiveMeshesAndRenderingGroups=!0,this.instance.setEnabled(e),this.scene.blockfreeActiveMeshesAndRenderingGroups=!1}}class h{static create(e){let t=new o;return t.canvas=document.createElement("canvas"),t.canvas.style.cssText="width: 100%;height: 100%;background-color: transparent;outline-width: 0;-webkit-tap-highlight-color:transparent;",e.appendChild(t.canvas),t.engine=new BABYLON.Engine(t.canvas,!0,{premultipliedAlpha:!0,preserveDrawingBuffer:!0,stencil:!0}),t.engine.setHardwareScalingLevel(.5),t.engine.enableOfflineSupport=!1,t.scene=new BABYLON.Scene(t.engine,{useGeometryUniqueIdsMap:!0,useClonedMeshMap:!0,useMaterialMeshMap:!0}),t.scene.useRightHandedSystem=!0,t.scene.getBoundingBoxRenderer().frontColor=BABYLON.Color3.Green(),t.scene.getBoundingBoxRenderer().showBackLines=!1,t}static load(){}}t.default=n}],o={},s.m=n,s.c=o,s.d=function(e,t,i){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)s.d(i,n,function(e){return t[e]}.bind(null,n));return i},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=1).default;function s(e){if(o[e])return o[e].exports;var t=o[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,s),t.l=!0,t.exports}var n,o});
|