@hology/core 0.0.53 → 0.0.54
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/ai/dynamic-tiled-navmesh.worker.js +1 -1
- package/dist/gameplay/services/world.js +1 -1
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.d.ts +1 -0
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/landscape/landscape-manager.d.ts +1 -0
- package/dist/scene/landscape/landscape-manager.js +1 -1
- package/dist/scene/materializer.d.ts +2 -0
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/model.d.ts +1 -0
- package/dist/scene/storage/storage.d.ts +33 -2
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/builtin/lambert-shader.d.ts +1 -1
- package/dist/shader/builtin/lambert-shader.js +1 -1
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/utils/math.js +1 -1
- package/dist/utils/three/transform-controls.d.ts +4 -2
- package/dist/utils/three/transform-controls.js +1 -1
- package/package.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
@@ -1,7 +1,9 @@
|
|
1
1
|
export class TransformControls extends Object3D<import("three").Object3DEventMap> {
|
2
2
|
constructor(camera: any, domElement: any);
|
3
|
+
raycaster: Raycaster;
|
3
4
|
domElement: any;
|
4
5
|
_gizmo: TransformControlsGizmo;
|
6
|
+
gizmo: TransformControlsGizmo;
|
5
7
|
_plane: TransformControlsPlane;
|
6
8
|
_offset: Vector3;
|
7
9
|
_startNorm: Vector3;
|
@@ -52,6 +54,8 @@ export class TransformControls extends Object3D<import("three").Object3DEventMap
|
|
52
54
|
update(): void;
|
53
55
|
isTransformControls: boolean;
|
54
56
|
}
|
57
|
+
import { Object3D } from 'three';
|
58
|
+
import { Raycaster } from 'three';
|
55
59
|
export class TransformControlsGizmo extends Object3D<import("three").Object3DEventMap> {
|
56
60
|
constructor();
|
57
61
|
type: string;
|
@@ -67,9 +71,7 @@ export class TransformControlsPlane extends Mesh<BufferGeometry<import("three").
|
|
67
71
|
updateMatrixWorld(force: any): void;
|
68
72
|
isTransformControlsPlane: boolean;
|
69
73
|
}
|
70
|
-
import { Object3D } from 'three';
|
71
74
|
import { Vector3 } from 'three';
|
72
75
|
import { Quaternion } from 'three';
|
73
|
-
import { Raycaster } from 'three';
|
74
76
|
import { BufferGeometry } from 'three';
|
75
77
|
import { Mesh } from 'three';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import{BoxGeometry as t,BufferGeometry as e,CylinderGeometry as i,DoubleSide as n,Euler as o,Float32BufferAttribute as s,Line as a,LineBasicMaterial as r,Matrix4 as h,Mesh as l,MeshBasicMaterial as c,Object3D as p,OctahedronGeometry as d,PlaneGeometry as w,Quaternion as m,Raycaster as u,SphereGeometry as y,TorusGeometry as b,Vector3 as v}from"three";const M=new u,P=new v,g=new v,S=new m,x={X:new v(1,0,0),Y:new v(0,1,0),Z:new v(0,0,1)},_={type:"change"},f={type:"mouseDown"},E={type:"mouseUp",mode:null},I={type:"objectChange"};class X extends p{constructor(t,e){super(),void 0===e&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),e=document),this.visible=!1,this.domElement=e,this.domElement.style.touchAction="none";const i=new B;this._gizmo=i,this.add(i);const n=new J;this._plane=n,this.add(n);const o=this;function s(t,e){let s=e;Object.defineProperty(o,t,{get:function(){return void 0!==s?s:e},set:function(e){s!==e&&(s=e,n[t]=e,i[t]=e,o.dispatchEvent({type:t+"-changed",value:e}),o.dispatchEvent(_))}}),o[t]=e,n[t]=e,i[t]=e}s("camera",t),s("object",void 0),s("enabled",!0),s("axis",null),s("mode","translate"),s("translationSnap",null),s("rotationSnap",null),s("scaleSnap",null),s("space","world"),s("size",1),s("dragging",!1),s("showX",!0),s("showY",!0),s("showZ",!0);const a=new v,r=new v,h=new m,l=new m,c=new v,p=new m,d=new v,w=new v,u=new v,y=new v;s("worldPosition",a),s("worldPositionStart",r),s("worldQuaternion",h),s("worldQuaternionStart",l),s("cameraPosition",c),s("cameraQuaternion",p),s("pointStart",d),s("pointEnd",w),s("rotationAxis",u),s("rotationAngle",0),s("eye",y),this._offset=new v,this._startNorm=new v,this._endNorm=new v,this._cameraScale=new v,this._parentPosition=new v,this._parentQuaternion=new m,this._parentQuaternionInv=new m,this._parentScale=new v,this._worldScaleStart=new v,this._worldQuaternionInv=new m,this._worldScale=new v,this._positionStart=new v,this._quaternionStart=new m,this._scaleStart=new v,this._getPointer=Q.bind(this),this._onPointerDown=Z.bind(this),this._onPointerHover=Y.bind(this),this._onPointerMove=A.bind(this),this._onPointerUp=z.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;M.setFromCamera(t,this.camera);const e=q(this._gizmo.picker[this.mode],M);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&0===t.button&&null!==this.axis){M.setFromCamera(t,this.camera);const e=q(this._plane,M,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,f.mode=this.mode,this.dispatchEvent(f)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let o=this.space;if("scale"===i?o="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(o="world"),void 0===n||null===e||!1===this.dragging||-1!==t.button)return;M.setFromCamera(t,this.camera);const s=q(this._plane,M,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===o&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===o&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===o&&(n.position.applyQuaternion(S.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===o&&(n.parent&&n.position.add(P.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(P.setFromMatrixPosition(n.parent.matrixWorld))));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),g.set(t,t,t)}else P.copy(this.pointStart),g.copy(this.pointEnd),P.applyQuaternion(this._worldQuaternionInv),g.applyQuaternion(this._worldQuaternionInv),g.divide(P),-1===e.search("X")&&(g.x=1),-1===e.search("Y")&&(g.y=1),-1===e.search("Z")&&(g.z=1);n.scale.copy(this._scaleStart).multiply(g),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(P.setFromMatrixPosition(this.camera.matrixWorld));"E"===e?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1):"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(P.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(x[e]),P.copy(x[e]),"local"===o&&P.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(P.cross(this.eye).normalize())*t),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===o&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(S.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(S.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(_),this.dispatchEvent(I)}}pointerUp(t){0===t.button&&(this.dragging&&null!==this.axis&&(E.mode=this.mode,this.dispatchEvent(E)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse((function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}attach(t){return this.object=t,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(_),this.dispatchEvent(I),this.pointStart.copy(this.pointEnd))}getRaycaster(){return M}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}update(){console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}}function Q(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function Y(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Z(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function A(t){this.enabled&&this.pointerMove(this._getPointer(t))}function z(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function q(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}X.prototype.isTransformControls=!0;const j=new o,T=new v(0,1,0),k=new v(0,0,0),W=new h,F=new m,H=new m,C=new v,L=new h,D=new v(1,0,0),O=new v(0,1,0),R=new v(0,0,1),N=new v,U=new v,G=new v;class B extends p{constructor(){super(),this.type="TransformControlsGizmo";const n=new c({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),o=new r({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),h=n.clone();h.opacity=.15;const w=o.clone();w.opacity=.5;const m=n.clone();m.color.setHex(16711680);const u=n.clone();u.color.setHex(65280);const v=n.clone();v.color.setHex(255);const M=n.clone();M.color.setHex(16711680),M.opacity=.5;const P=n.clone();P.color.setHex(65280),P.opacity=.5;const g=n.clone();g.color.setHex(255),g.opacity=.5;const S=n.clone();S.opacity=.25;const x=n.clone();x.color.setHex(16776960),x.opacity=.25;n.clone().color.setHex(16776960);const _=n.clone();_.color.setHex(7895160);const f=new i(0,.04,.1,12);f.translate(0,.05,0);const E=new t(.08,.08,.08);E.translate(0,.04,0);const I=new e;I.setAttribute("position",new s([0,0,0,1,0,0],3));const X=new i(.0075,.0075,.5,3);function Q(t,e){const i=new b(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}X.translate(0,.25,0);const Y={X:[[new l(f,m),[.5,0,0],[0,0,-Math.PI/2]],[new l(f,m),[-.5,0,0],[0,0,Math.PI/2]],[new l(X,m),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new l(f,u),[0,.5,0]],[new l(f,u),[0,-.5,0],[Math.PI,0,0]],[new l(X,u)]],Z:[[new l(f,v),[0,0,.5],[Math.PI/2,0,0]],[new l(f,v),[0,0,-.5],[-Math.PI/2,0,0]],[new l(X,v),null,[Math.PI/2,0,0]]],XYZ:[[new l(new d(.1,0),S.clone()),[0,0,0]]],XY:[[new l(new t(.15,.15,.01),g.clone()),[.15,.15,0]]],YZ:[[new l(new t(.15,.15,.01),M.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new l(new t(.15,.15,.01),P.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},Z={X:[[new l(new i(.2,0,.6,4),h),[.3,0,0],[0,0,-Math.PI/2]],[new l(new i(.2,0,.6,4),h),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new l(new i(.2,0,.6,4),h),[0,.3,0]],[new l(new i(.2,0,.6,4),h),[0,-.3,0],[0,0,Math.PI]]],Z:[[new l(new i(.2,0,.6,4),h),[0,0,.3],[Math.PI/2,0,0]],[new l(new i(.2,0,.6,4),h),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new l(new d(.2,0),h)]],XY:[[new l(new t(.2,.2,.01),h),[.15,.15,0]]],YZ:[[new l(new t(.2,.2,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new l(new t(.2,.2,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new l(new d(.01,2),w),null,null,null,"helper"]],END:[[new l(new d(.01,2),w),null,null,null,"helper"]],DELTA:[[new a(function(){const t=new e;return t.setAttribute("position",new s([0,0,0,1,1,1],3)),t}(),w),null,null,null,"helper"]],X:[[new a(I,w.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new a(I,w.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new a(I,w.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={XYZE:[[new l(Q(.5,1),_),null,[0,Math.PI/2,0]]],X:[[new l(Q(.5,.5),m)]],Y:[[new l(Q(.5,.5),u),null,[0,0,-Math.PI/2]]],Z:[[new l(Q(.5,.5),v),null,[0,Math.PI/2,0]]],E:[[new l(Q(.75,1),x),null,[0,Math.PI/2,0]]]},q={AXIS:[[new a(I,w.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},j={XYZE:[[new l(new y(.25,10,8),h)]],X:[[new l(new b(.5,.1,4,24),h),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l(new b(.5,.1,4,24),h),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l(new b(.5,.1,4,24),h),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l(new b(.75,.1,2,24),h)]]},T={X:[[new l(E,m),[.5,0,0],[0,0,-Math.PI/2]],[new l(X,m),[0,0,0],[0,0,-Math.PI/2]],[new l(E,m),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new l(E,u),[0,.5,0]],[new l(X,u)],[new l(E,u),[0,-.5,0],[0,0,Math.PI]]],Z:[[new l(E,v),[0,0,.5],[Math.PI/2,0,0]],[new l(X,v),[0,0,0],[Math.PI/2,0,0]],[new l(E,v),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new l(new t(.15,.15,.01),g),[.15,.15,0]]],YZ:[[new l(new t(.15,.15,.01),M),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new l(new t(.15,.15,.01),P),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new l(new t(.1,.1,.1),S.clone())]]},k={X:[[new l(new i(.2,0,.6,4),h),[.3,0,0],[0,0,-Math.PI/2]],[new l(new i(.2,0,.6,4),h),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new l(new i(.2,0,.6,4),h),[0,.3,0]],[new l(new i(.2,0,.6,4),h),[0,-.3,0],[0,0,Math.PI]]],Z:[[new l(new i(.2,0,.6,4),h),[0,0,.3],[Math.PI/2,0,0]],[new l(new i(.2,0,.6,4),h),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new l(new t(.2,.2,.01),h),[.15,.15,0]]],YZ:[[new l(new t(.2,.2,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new l(new t(.2,.2,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new l(new t(.2,.2,.2),h),[0,0,0]]]},W={X:[[new a(I,w.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new a(I,w.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new a(I,w.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function F(t){const e=new p;for(const i in t)for(let n=t[i].length;n--;){const o=t[i][n][0].clone(),s=t[i][n][1],a=t[i][n][2],r=t[i][n][3],h=t[i][n][4];o.name=i,o.tag=h,s&&o.position.set(s[0],s[1],s[2]),a&&o.rotation.set(a[0],a[1],a[2]),r&&o.scale.set(r[0],r[1],r[2]),o.updateMatrix();const l=o.geometry.clone();l.applyMatrix4(o.matrix),o.geometry=l,o.renderOrder=1/0,o.position.set(0,0,0),o.rotation.set(0,0,0),o.scale.set(1,1,1),e.add(o)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=F(Y)),this.add(this.gizmo.rotate=F(z)),this.add(this.gizmo.scale=F(T)),this.add(this.picker.translate=F(Z)),this.add(this.picker.rotate=F(j)),this.add(this.picker.scale=F(k)),this.add(this.helper.translate=F(A)),this.add(this.helper.rotate=F(q)),this.add(this.helper.scale=F(W)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:H;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let o;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),o=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(o*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(T.copy(D).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(T.copy(O).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(T.copy(R).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(T.copy(R).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(T.copy(D).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(T.copy(O).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(F.copy(e),T.copy(this.eye).applyQuaternion(S.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(W.lookAt(this.eye,k,O)),"X"===n.name&&(S.setFromAxisAngle(D,Math.atan2(-T.y,T.z)),S.multiplyQuaternions(F,S),n.quaternion.copy(S)),"Y"===n.name&&(S.setFromAxisAngle(O,Math.atan2(T.x,T.z)),S.multiplyQuaternions(F,S),n.quaternion.copy(S)),"Z"===n.name&&(S.setFromAxisAngle(R,Math.atan2(T.y,T.x)),S.multiplyQuaternions(F,S),n.quaternion.copy(S)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some((function(t){return n.name===t})))&&(n.material.color.setHex(16776960),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.position.copy(this.worldPositionStart),n.visible=!!this.axis,"X"===this.axis&&(S.setFromEuler(j.set(0,0,0)),n.quaternion.copy(e).multiply(S),Math.abs(T.copy(D).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(S.setFromEuler(j.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(S),Math.abs(T.copy(O).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(S.setFromEuler(j.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(S),Math.abs(T.copy(R).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(S.setFromEuler(j.set(0,Math.PI/2,0)),T.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(W.lookAt(k,T,O)),n.quaternion.multiply(S),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),P.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),P.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(P),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}B.prototype.isTransformControlsGizmo=!0;class J extends l{constructor(){super(new w(1e5,1e5,2,2),new c({visible:!1,wireframe:!0,side:n,transparent:!0,opacity:.1,toneMapped:!1})),this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),N.copy(D).applyQuaternion("local"===e?this.worldQuaternion:H),U.copy(O).applyQuaternion("local"===e?this.worldQuaternion:H),G.copy(R).applyQuaternion("local"===e?this.worldQuaternion:H),T.copy(U),this.mode){case"translate":case"scale":switch(this.axis){case"X":T.copy(this.eye).cross(N),C.copy(N).cross(T);break;case"Y":T.copy(this.eye).cross(U),C.copy(U).cross(T);break;case"Z":T.copy(this.eye).cross(G),C.copy(G).cross(T);break;case"XY":C.copy(G);break;case"YZ":C.copy(N);break;case"XZ":T.copy(G),C.copy(U);break;case"XYZ":case"E":C.set(0,0,0)}break;default:C.set(0,0,0)}0===C.length()?this.quaternion.copy(this.cameraQuaternion):(L.lookAt(P.set(0,0,0),C,T),this.quaternion.setFromRotationMatrix(L)),super.updateMatrixWorld(t)}}J.prototype.isTransformControlsPlane=!0;export{X as TransformControls,B as TransformControlsGizmo,J as TransformControlsPlane};
|
1
|
+
import{BoxGeometry as t,BufferGeometry as e,CylinderGeometry as i,DoubleSide as n,Euler as o,Float32BufferAttribute as s,Line as a,LineBasicMaterial as r,Matrix4 as h,Mesh as l,MeshBasicMaterial as c,Object3D as p,OctahedronGeometry as d,PlaneGeometry as m,Quaternion as w,Raycaster as u,SphereGeometry as y,TorusGeometry as b,Vector3 as v}from"three";const M=new u,P=new v,g=new v,S=new w,x={X:new v(1,0,0),Y:new v(0,1,0),Z:new v(0,0,1)},_={type:"change"},f={type:"mouseDown"},E={type:"mouseUp",mode:null},I={type:"objectChange"};export class TransformControls extends p{constructor(t,e){super(),this.raycaster=M,void 0===e&&(console.warn('THREE.TransformControls: The second parameter "domElement" is now mandatory.'),e=document),this.visible=!1,this.domElement=e,this.domElement.style.touchAction="none";const i=new G;this._gizmo=i,this.gizmo=i,this.add(i);const n=new B;this._plane=n,this.add(n);const o=this;function s(t,e){let s=e;Object.defineProperty(o,t,{get:function(){return void 0!==s?s:e},set:function(e){s!==e&&(s=e,n[t]=e,i[t]=e,o.dispatchEvent({type:t+"-changed",value:e}),o.dispatchEvent(_))}}),o[t]=e,n[t]=e,i[t]=e}s("camera",t),s("object",void 0),s("enabled",!0),s("axis",null),s("mode","translate"),s("translationSnap",null),s("rotationSnap",null),s("scaleSnap",null),s("space","world"),s("size",1),s("dragging",!1),s("showX",!0),s("showY",!0),s("showZ",!0);const a=new v,r=new v,h=new w,l=new w,c=new v,p=new w,d=new v,m=new v,u=new v,y=new v;s("worldPosition",a),s("worldPositionStart",r),s("worldQuaternion",h),s("worldQuaternionStart",l),s("cameraPosition",c),s("cameraQuaternion",p),s("pointStart",d),s("pointEnd",m),s("rotationAxis",u),s("rotationAngle",0),s("eye",y),this._offset=new v,this._startNorm=new v,this._endNorm=new v,this._cameraScale=new v,this._parentPosition=new v,this._parentQuaternion=new w,this._parentQuaternionInv=new w,this._parentScale=new v,this._worldScaleStart=new v,this._worldQuaternionInv=new w,this._worldScale=new v,this._positionStart=new v,this._quaternionStart=new w,this._scaleStart=new v,this._getPointer=X.bind(this),this._onPointerDown=Y.bind(this),this._onPointerHover=Q.bind(this),this._onPointerMove=Z.bind(this),this._onPointerUp=A.bind(this),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp)}updateMatrixWorld(){void 0!==this.object&&(this.object.updateMatrixWorld(),null===this.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):this.object.parent.matrixWorld.decompose(this._parentPosition,this._parentQuaternion,this._parentScale),this.object.matrixWorld.decompose(this.worldPosition,this.worldQuaternion,this._worldScale),this._parentQuaternionInv.copy(this._parentQuaternion).invert(),this._worldQuaternionInv.copy(this.worldQuaternion).invert()),this.camera.updateMatrixWorld(),this.camera.matrixWorld.decompose(this.cameraPosition,this.cameraQuaternion,this._cameraScale),this.eye.copy(this.cameraPosition).sub(this.worldPosition).normalize(),super.updateMatrixWorld(this)}pointerHover(t){if(void 0===this.object||!0===this.dragging)return;M.setFromCamera(t,this.camera);const e=z(this._gizmo.picker[this.mode],M);this.axis=e?e.object.name:null}pointerDown(t){if(void 0!==this.object&&!0!==this.dragging&&0===t.button&&null!==this.axis){M.setFromCamera(t,this.camera);const e=z(this._plane,M,!0);e&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(e.point).sub(this.worldPositionStart)),this.dragging=!0,f.mode=this.mode,this.dispatchEvent(f)}}pointerMove(t){const e=this.axis,i=this.mode,n=this.object;let o=this.space;if("scale"===i?o="local":"E"!==e&&"XYZE"!==e&&"XYZ"!==e||(o="world"),void 0===n||null===e||!1===this.dragging||-1!==t.button)return;M.setFromCamera(t,this.camera);const s=z(this._plane,M,!0);if(s){if(this.pointEnd.copy(s.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===o&&"XYZ"!==e&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===e.indexOf("X")&&(this._offset.x=0),-1===e.indexOf("Y")&&(this._offset.y=0),-1===e.indexOf("Z")&&(this._offset.z=0),"local"===o&&"XYZ"!==e?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),n.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===o&&(n.position.applyQuaternion(S.copy(this._quaternionStart).invert()),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.position.applyQuaternion(this._quaternionStart)),"world"===o&&(n.parent&&n.position.add(P.setFromMatrixPosition(n.parent.matrixWorld)),-1!==e.search("X")&&(n.position.x=Math.round(n.position.x/this.translationSnap)*this.translationSnap),-1!==e.search("Y")&&(n.position.y=Math.round(n.position.y/this.translationSnap)*this.translationSnap),-1!==e.search("Z")&&(n.position.z=Math.round(n.position.z/this.translationSnap)*this.translationSnap),n.parent&&n.position.sub(P.setFromMatrixPosition(n.parent.matrixWorld))));else if("scale"===i){if(-1!==e.search("XYZ")){let t=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(t*=-1),g.set(t,t,t)}else P.copy(this.pointStart),g.copy(this.pointEnd),P.applyQuaternion(this._worldQuaternionInv),g.applyQuaternion(this._worldQuaternionInv),g.divide(P),-1===e.search("X")&&(g.x=1),-1===e.search("Y")&&(g.y=1),-1===e.search("Z")&&(g.z=1);n.scale.copy(this._scaleStart).multiply(g),this.scaleSnap&&(-1!==e.search("X")&&(n.scale.x=Math.round(n.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Y")&&(n.scale.y=Math.round(n.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==e.search("Z")&&(n.scale.z=Math.round(n.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const t=20/this.worldPosition.distanceTo(P.setFromMatrixPosition(this.camera.matrixWorld));"E"===e?(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1):"XYZE"===e?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(P.copy(this.rotationAxis).cross(this.eye))*t):"X"!==e&&"Y"!==e&&"Z"!==e||(this.rotationAxis.copy(x[e]),P.copy(x[e]),"local"===o&&P.applyQuaternion(this.worldQuaternion),this.rotationAngle=this._offset.dot(P.cross(this.eye).normalize())*t),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===o&&"E"!==e&&"XYZE"!==e?(n.quaternion.copy(this._quaternionStart),n.quaternion.multiply(S.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),n.quaternion.copy(S.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),n.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(_),this.dispatchEvent(I)}}pointerUp(t){0===t.button&&(this.dragging&&null!==this.axis&&(E.mode=this.mode,this.dispatchEvent(E)),this.dragging=!1,this.axis=null)}dispose(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.traverse((function(t){t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()}))}attach(t){return this.object=t,this.visible=!0,this}detach(){return this.object=void 0,this.visible=!1,this.axis=null,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(_),this.dispatchEvent(I),this.pointStart.copy(this.pointEnd))}getRaycaster(){return M}getMode(){return this.mode}setMode(t){this.mode=t}setTranslationSnap(t){this.translationSnap=t}setRotationSnap(t){this.rotationSnap=t}setScaleSnap(t){this.scaleSnap=t}setSize(t){this.size=t}setSpace(t){this.space=t}update(){console.warn("THREE.TransformControls: update function has no more functionality and therefore has been deprecated.")}}function X(t){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:t.button};{const e=this.domElement.getBoundingClientRect();return{x:(t.clientX-e.left)/e.width*2-1,y:-(t.clientY-e.top)/e.height*2+1,button:t.button}}}function Q(t){if(this.enabled)switch(t.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(t))}}function Y(t){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(t.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(t)),this.pointerDown(this._getPointer(t)))}function Z(t){this.enabled&&this.pointerMove(this._getPointer(t))}function A(t){this.enabled&&(this.domElement.releasePointerCapture(t.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(t)))}function z(t,e,i){const n=e.intersectObject(t,!0);for(let t=0;t<n.length;t++)if(n[t].object.visible||i)return n[t];return!1}TransformControls.prototype.isTransformControls=!0;const q=new o,T=new v(0,1,0),j=new v(0,0,0),k=new h,W=new w,C=new w,F=new v,H=new h,L=new v(1,0,0),D=new v(0,1,0),O=new v(0,0,1),R=new v,N=new v,U=new v;class G extends p{constructor(){super(),this.type="TransformControlsGizmo";const n=new c({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),o=new r({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),h=n.clone();h.opacity=.15;const m=o.clone();m.opacity=.5;const w=n.clone();w.color.setHex(16711680);const u=n.clone();u.color.setHex(65280);const v=n.clone();v.color.setHex(255);const M=n.clone();M.color.setHex(16711680),M.opacity=.5;const P=n.clone();P.color.setHex(65280),P.opacity=.5;const g=n.clone();g.color.setHex(255),g.opacity=.5;const S=n.clone();S.opacity=.25;const x=n.clone();x.color.setHex(16776960),x.opacity=.25;n.clone().color.setHex(16776960);const _=n.clone();_.color.setHex(7895160);const f=new i(0,.04,.1,12);f.translate(0,.05,0);const E=new t(.08,.08,.08);E.translate(0,.04,0);const I=new e;I.setAttribute("position",new s([0,0,0,1,0,0],3));const X=new i(.0075,.0075,.5,3);function Q(t,e){const i=new b(t,.0075,3,64,e*Math.PI*2);return i.rotateY(Math.PI/2),i.rotateX(Math.PI/2),i}X.translate(0,.25,0);const Y={X:[[new l(f,w),[.5,0,0],[0,0,-Math.PI/2]],[new l(f,w),[-.5,0,0],[0,0,Math.PI/2]],[new l(X,w),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new l(f,u),[0,.5,0]],[new l(f,u),[0,-.5,0],[Math.PI,0,0]],[new l(X,u)]],Z:[[new l(f,v),[0,0,.5],[Math.PI/2,0,0]],[new l(f,v),[0,0,-.5],[-Math.PI/2,0,0]],[new l(X,v),null,[Math.PI/2,0,0]]],XYZ:[[new l(new d(.1,0),S.clone()),[0,0,0]]],XY:[[new l(new t(.15,.15,.01),g.clone()),[.15,.15,0]]],YZ:[[new l(new t(.15,.15,.01),M.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new l(new t(.15,.15,.01),P.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},Z={X:[[new l(new i(.2,0,.6,4),h),[.3,0,0],[0,0,-Math.PI/2]],[new l(new i(.2,0,.6,4),h),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new l(new i(.2,0,.6,4),h),[0,.3,0]],[new l(new i(.2,0,.6,4),h),[0,-.3,0],[0,0,Math.PI]]],Z:[[new l(new i(.2,0,.6,4),h),[0,0,.3],[Math.PI/2,0,0]],[new l(new i(.2,0,.6,4),h),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new l(new d(.2,0),h)]],XY:[[new l(new t(.2,.2,.01),h),[.15,.15,0]]],YZ:[[new l(new t(.2,.2,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new l(new t(.2,.2,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]]},A={START:[[new l(new d(.01,2),m),null,null,null,"helper"]],END:[[new l(new d(.01,2),m),null,null,null,"helper"]],DELTA:[[new a(function(){const t=new e;return t.setAttribute("position",new s([0,0,0,1,1,1],3)),t}(),m),null,null,null,"helper"]],X:[[new a(I,m.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new a(I,m.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new a(I,m.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={XYZE:[[new l(Q(.5,1),_),null,[0,Math.PI/2,0]]],X:[[new l(Q(.5,.5),w)]],Y:[[new l(Q(.5,.5),u),null,[0,0,-Math.PI/2]]],Z:[[new l(Q(.5,.5),v),null,[0,Math.PI/2,0]]],E:[[new l(Q(.75,1),x),null,[0,Math.PI/2,0]]]},q={AXIS:[[new a(I,m.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},T={XYZE:[[new l(new y(.25,10,8),h)]],X:[[new l(new b(.5,.1,4,24),h),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new l(new b(.5,.1,4,24),h),[0,0,0],[Math.PI/2,0,0]]],Z:[[new l(new b(.5,.1,4,24),h),[0,0,0],[0,0,-Math.PI/2]]],E:[[new l(new b(.75,.1,2,24),h)]]},j={X:[[new l(E,w),[.5,0,0],[0,0,-Math.PI/2]],[new l(X,w),[0,0,0],[0,0,-Math.PI/2]],[new l(E,w),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new l(E,u),[0,.5,0]],[new l(X,u)],[new l(E,u),[0,-.5,0],[0,0,Math.PI]]],Z:[[new l(E,v),[0,0,.5],[Math.PI/2,0,0]],[new l(X,v),[0,0,0],[Math.PI/2,0,0]],[new l(E,v),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new l(new t(.15,.15,.01),g),[.15,.15,0]]],YZ:[[new l(new t(.15,.15,.01),M),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new l(new t(.15,.15,.01),P),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new l(new t(.1,.1,.1),S.clone())]]},k={X:[[new l(new i(.2,0,.6,4),h),[.3,0,0],[0,0,-Math.PI/2]],[new l(new i(.2,0,.6,4),h),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new l(new i(.2,0,.6,4),h),[0,.3,0]],[new l(new i(.2,0,.6,4),h),[0,-.3,0],[0,0,Math.PI]]],Z:[[new l(new i(.2,0,.6,4),h),[0,0,.3],[Math.PI/2,0,0]],[new l(new i(.2,0,.6,4),h),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new l(new t(.2,.2,.01),h),[.15,.15,0]]],YZ:[[new l(new t(.2,.2,.01),h),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new l(new t(.2,.2,.01),h),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new l(new t(.2,.2,.2),h),[0,0,0]]]},W={X:[[new a(I,m.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new a(I,m.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new a(I,m.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function C(t){const e=new p;for(const i in t)for(let n=t[i].length;n--;){const o=t[i][n][0].clone(),s=t[i][n][1],a=t[i][n][2],r=t[i][n][3],h=t[i][n][4];o.name=i,o.tag=h,s&&o.position.set(s[0],s[1],s[2]),a&&o.rotation.set(a[0],a[1],a[2]),r&&o.scale.set(r[0],r[1],r[2]),o.updateMatrix();const l=o.geometry.clone();l.applyMatrix4(o.matrix),o.geometry=l,o.renderOrder=1/0,o.position.set(0,0,0),o.rotation.set(0,0,0),o.scale.set(1,1,1),e.add(o)}return e}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=C(Y)),this.add(this.gizmo.rotate=C(z)),this.add(this.gizmo.scale=C(j)),this.add(this.picker.translate=C(Z)),this.add(this.picker.rotate=C(T)),this.add(this.picker.scale=C(k)),this.add(this.helper.translate=C(A)),this.add(this.helper.rotate=C(q)),this.add(this.helper.scale=C(W)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(t){const e="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:C;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let t=0;t<i.length;t++){const n=i[t];let o;if(n.visible=!0,n.rotation.set(0,0,0),n.position.copy(this.worldPosition),o=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),n.scale.set(1,1,1).multiplyScalar(o*this.size/4),"helper"!==n.tag){if(n.quaternion.copy(e),"translate"===this.mode||"scale"===this.mode){const t=.99,i=.2;"X"===n.name&&Math.abs(T.copy(L).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Y"===n.name&&Math.abs(T.copy(D).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"Z"===n.name&&Math.abs(T.copy(O).applyQuaternion(e).dot(this.eye))>t&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XY"===n.name&&Math.abs(T.copy(O).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"YZ"===n.name&&Math.abs(T.copy(L).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1),"XZ"===n.name&&Math.abs(T.copy(D).applyQuaternion(e).dot(this.eye))<i&&(n.scale.set(1e-10,1e-10,1e-10),n.visible=!1)}else"rotate"===this.mode&&(W.copy(e),T.copy(this.eye).applyQuaternion(S.copy(e).invert()),-1!==n.name.search("E")&&n.quaternion.setFromRotationMatrix(k.lookAt(this.eye,j,D)),"X"===n.name&&(S.setFromAxisAngle(L,Math.atan2(-T.y,T.z)),S.multiplyQuaternions(W,S),n.quaternion.copy(S)),"Y"===n.name&&(S.setFromAxisAngle(D,Math.atan2(T.x,T.z)),S.multiplyQuaternions(W,S),n.quaternion.copy(S)),"Z"===n.name&&(S.setFromAxisAngle(O,Math.atan2(T.y,T.x)),S.multiplyQuaternions(W,S),n.quaternion.copy(S)));n.visible=n.visible&&(-1===n.name.indexOf("X")||this.showX),n.visible=n.visible&&(-1===n.name.indexOf("Y")||this.showY),n.visible=n.visible&&(-1===n.name.indexOf("Z")||this.showZ),n.visible=n.visible&&(-1===n.name.indexOf("E")||this.showX&&this.showY&&this.showZ),n.material._color=n.material._color||n.material.color.clone(),n.material._opacity=n.material._opacity||n.material.opacity,n.material.color.copy(n.material._color),n.material.opacity=n.material._opacity,this.enabled&&this.axis&&(n.name===this.axis||this.axis.split("").some((function(t){return n.name===t})))&&(n.material.color.setHex(16776960),n.material.opacity=1)}else n.visible=!1,"AXIS"===n.name?(n.position.copy(this.worldPositionStart),n.visible=!!this.axis,"X"===this.axis&&(S.setFromEuler(q.set(0,0,0)),n.quaternion.copy(e).multiply(S),Math.abs(T.copy(L).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Y"===this.axis&&(S.setFromEuler(q.set(0,0,Math.PI/2)),n.quaternion.copy(e).multiply(S),Math.abs(T.copy(D).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"Z"===this.axis&&(S.setFromEuler(q.set(0,Math.PI/2,0)),n.quaternion.copy(e).multiply(S),Math.abs(T.copy(O).applyQuaternion(e).dot(this.eye))>.9&&(n.visible=!1)),"XYZE"===this.axis&&(S.setFromEuler(q.set(0,Math.PI/2,0)),T.copy(this.rotationAxis),n.quaternion.setFromRotationMatrix(k.lookAt(j,T,D)),n.quaternion.multiply(S),n.visible=this.dragging),"E"===this.axis&&(n.visible=!1)):"START"===n.name?(n.position.copy(this.worldPositionStart),n.visible=this.dragging):"END"===n.name?(n.position.copy(this.worldPosition),n.visible=this.dragging):"DELTA"===n.name?(n.position.copy(this.worldPositionStart),n.quaternion.copy(this.worldQuaternionStart),P.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),P.applyQuaternion(this.worldQuaternionStart.clone().invert()),n.scale.copy(P),n.visible=this.dragging):(n.quaternion.copy(e),this.dragging?n.position.copy(this.worldPositionStart):n.position.copy(this.worldPosition),this.axis&&(n.visible=-1!==this.axis.search(n.name)))}super.updateMatrixWorld(t)}}G.prototype.isTransformControlsGizmo=!0;class B extends l{constructor(){super(new m(1e5,1e5,2,2),new c({visible:!1,wireframe:!0,side:n,transparent:!0,opacity:.1,toneMapped:!1})),this.type="TransformControlsPlane"}updateMatrixWorld(t){let e=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(e="local"),R.copy(L).applyQuaternion("local"===e?this.worldQuaternion:C),N.copy(D).applyQuaternion("local"===e?this.worldQuaternion:C),U.copy(O).applyQuaternion("local"===e?this.worldQuaternion:C),T.copy(N),this.mode){case"translate":case"scale":switch(this.axis){case"X":T.copy(this.eye).cross(R),F.copy(R).cross(T);break;case"Y":T.copy(this.eye).cross(N),F.copy(N).cross(T);break;case"Z":T.copy(this.eye).cross(U),F.copy(U).cross(T);break;case"XY":F.copy(U);break;case"YZ":F.copy(R);break;case"XZ":T.copy(U),F.copy(N);break;case"XYZ":case"E":F.set(0,0,0)}break;default:F.set(0,0,0)}0===F.length()?this.quaternion.copy(this.cameraQuaternion):(H.lookAt(P.set(0,0,0),F,T),this.quaternion.setFromRotationMatrix(H)),super.updateMatrixWorld(t)}}B.prototype.isTransformControlsPlane=!0;export{G as TransformControlsGizmo,B as TransformControlsPlane};
|
2
2
|
/*
|
3
3
|
* Copyright (©) 2023. All rights reserved.
|
4
4
|
* See the LICENSE.md file for details.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@hology/core",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.54",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"type": "module",
|
@@ -94,12 +94,13 @@
|
|
94
94
|
"three-csm": "^4.2.1",
|
95
95
|
"three-mesh-bvh": "^0.7.5",
|
96
96
|
"three-nebula": "^10.0.3",
|
97
|
-
"three-shader-graph": "^0.1.
|
97
|
+
"three-shader-graph": "^0.1.29",
|
98
98
|
"three-stdlib": "2.30.3",
|
99
99
|
"ts-key-enum": "^2.0.12",
|
100
100
|
"typedi": "^0.10.0"
|
101
101
|
},
|
102
102
|
"devDependencies": {
|
103
|
+
"@types/chokidar": "^2.1.3",
|
103
104
|
"@types/node": "^20.3.1",
|
104
105
|
"@types/offscreencanvas": "^2019.7.0",
|
105
106
|
"@types/three": "0.166.0",
|