minerender 2.1.0-alpha.130 → 2.1.0-alpha.131

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.
@@ -17,13 +17,13 @@ function applyElementRotation(rotation, geometry) {
17
17
  break;
18
18
  }
19
19
  if (rotation.rescale) {
20
- if (Math.abs(rotation.angle) === 22.5) {
21
- const s = 1 / Math.cos(0.39269909262657166);
22
- geometry.scale(s, 1, s);
23
- } else {
24
- const s = 1 / Math.cos(0.7853981852531433);
25
- geometry.scale(s, 1, s);
26
- }
20
+ const angle = toRadians(rotation.angle);
21
+ const s = 1 / Math.max(Math.abs(Math.cos(angle)), Math.abs(Math.sin(angle)));
22
+ geometry.scale(
23
+ rotation.axis === Axis.X ? 1 : s,
24
+ rotation.axis === Axis.Y ? 1 : s,
25
+ rotation.axis === Axis.Z ? 1 : s
26
+ );
27
27
  }
28
28
  geometry.translate(origin.x, origin.y, origin.z);
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/util/model.ts"],"sourcesContent":["/// https://stackoverflow.com/questions/42812861/three-js-pivot-point/42866733#42866733\n// obj - your object (THREE.Object3D or derived)\n// point - the point of rotation (THREE.Vector3)\n// axis - the axis of rotation (normalized THREE.Vector3)\n// theta - radian value of rotation\nimport { ElementRotation } from \"../model/ModelElement\";\nimport type { BufferGeometry } from \"three\";\nimport { Axis } from \"../Axis\";\nimport { toRadians } from \"./util\";\nimport { AxesHelper, Box3, BoxGeometry, EdgesGeometry, LineBasicMaterial, LineSegments, Matrix4, Mesh, Object3D, Quaternion, Vector3, Vector4 } from \"three\";\n\nfunction rotateAboutPoint(obj: Object3D, point: Vector3, axis: Vector3, theta: number) {\n obj.position.sub(point); // remove the offset\n obj.position.applyAxisAngle(axis, theta); // rotate the POSITION\n obj.position.add(point); // re-add the offset\n\n obj.rotateOnAxis(axis, theta); // rotate the OBJECT\n}\n\n/** Rotates geometry in place around the element's origin. The supplied angle is in degrees. */\nexport function applyElementRotation(rotation: ElementRotation, geometry: BufferGeometry) {\n const origin = new Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);\n // origin.multiplyScalar(0.0625);\n\n\n // let axisVector: Vector3;\n // let inverseAxisVector: Vector3;\n // switch (rotation.axis) {\n // case Axis.X:\n // axisVector = new Vector3(1, 0, 0);\n // inverseAxisVector = new Vector3(0, 1, 1);\n // break;\n // case Axis.Y:\n // axisVector = new Vector3(0, 1, 0);\n // inverseAxisVector = new Vector3(1, 0, 1);\n // break;\n // case Axis.Z:\n // axisVector = new Vector3(0, 0, 1);\n // inverseAxisVector = new Vector3(1, 1, 0);\n // break;\n // }\n // const quat = new Quaternion().setFromAxisAngle(axisVector, (rotation.angle*0.017453292));\n // if (rotation.rescale) {\n // if (Math.abs(rotation.angle) === 22.5) {\n // inverseAxisVector.multiplyScalar(1.0 / Math.cos(0.39269909262657166) - 1.0)\n // }else {\n // inverseAxisVector.multiplyScalar(1.0 / Math.cos(0.7853981852531433) - 1.0)\n // }\n //\n // inverseAxisVector.add(new Vector3(1, 1, 1));\n // }else{\n // inverseAxisVector.set(1, 1, 1);\n // }\n\n // Vector4 vec4 = new Vector4(geometry.getAttribute(\"position\").)\n\n\n // subtract origin\n geometry.translate(-origin.x, -origin.y, -origin.z);\n // apply rotation\n switch (rotation.axis) {\n case Axis.X:\n geometry.rotateX(toRadians(rotation.angle));\n break;\n case Axis.Y:\n geometry.rotateY(toRadians(rotation.angle));\n break;\n case Axis.Z:\n geometry.rotateZ(toRadians(rotation.angle));\n break;\n }\n\n\n // if (rotation.rescale) {\n // console.log(\"angle\", Math.abs(rotation.angle) )\n // if (Math.abs(rotation.angle) === 22.5) {\n // const s = 2;\n // geometry.scale(s, s, s);\n // }else{\n // const s = 2;\n // geometry.scale(s, s, s);\n // }\n // }\n if (rotation.rescale) {\n //TODO: y height seems a bit too tall (1 pixel)\n if (Math.abs(rotation.angle) === 22.5) {\n const s = 1.0 / Math.cos(0.39269909262657166);\n geometry.scale(s, 1, s);\n }else {\n const s = 1.0 / Math.cos(0.7853981852531433);\n geometry.scale(s, 1, s);\n }\n }\n\n // add back origin\n geometry.translate(origin.x, origin.y, origin.z);\n\n\n}\n\n/** Rotates an object around a local axis by an angle in degrees. */\nexport function applyGenericRotation(axis: Axis, rotation: number, obj: Object3D) {\n\n\n // obj.position.sub(new Vector3(8,8,8).add(obj.position))\n //\n // switch (axis) {\n // case Axis.X:\n // obj.position.applyAxisAngle(new Vector3(1, 0, 0), toRadians(rotation));\n // break;\n // case Axis.Y:\n // obj.position.applyAxisAngle(new Vector3(0, 1, 0), toRadians(rotation));\n // break;\n // case Axis.Z:\n // obj.position.applyAxisAngle(new Vector3(0, 0, 1), toRadians(rotation));\n // break;\n // }\n //\n // obj.position.add(new Vector3(8,8,8).add(obj.position))\n\n switch (axis) {\n case Axis.X:\n obj.rotateOnAxis(new Vector3(1, 0, 0), toRadians(rotation));\n break;\n case Axis.Y:\n obj.rotateOnAxis(new Vector3(0, 1, 0), toRadians(rotation));\n break;\n case Axis.Z:\n obj.rotateOnAxis(new Vector3(0, 0, 1), toRadians(rotation));\n break;\n }\n\n // subtract origin\n // obj.translateX(-8);\n // obj.translateZ(-8);\n // obj.translateY(-8);\n // // apply rotation\n // switch (axis) {\n // case Axis.X:\n // obj.rotateX(toRadians(rotation));\n // // matrix.makeRotationX(toRadians(rotation));\n // break;\n // case Axis.Y:\n // obj.rotateY(toRadians(rotation));\n // // matrix.makeRotationY(toRadians(rotation));\n // break;\n // case Axis.Z:\n // obj.rotateZ(toRadians(rotation));\n // // matrix.makeRotationZ(toRadians(rotation));\n // break;\n // }\n // // add back origin\n // obj.translateX(8);\n // obj.translateZ(8);\n // obj.translateY(8);\n\n // obj.applyMatrix4(matrix);\n}\n\nexport function addBox3WireframeToObject(box: Box3, obj: Object3D, color: number = 0xffffff, w: number = 2) {\n let size = new Vector3();\n box.getSize(size);\n\n let boxGeo = new BoxGeometry(size.x, size.y, size.z, 1, 1, 1);\n // boxGeo.translate(box.min.x, box.min.y, box.min.z);\n let wireGeo = new EdgesGeometry(boxGeo);\n let wireMat = new LineBasicMaterial({ color: color, linewidth: w, })\n let wireframe = new LineSegments(wireGeo, wireMat);\n obj.add(wireframe);\n\n let axes = new AxesHelper(1);\n obj.add(axes);\n}\n\n\nexport function addWireframeToObject(obj: Object3D, color: number = 0xffffff, w: number = 2) {\n let boxGeo = new BoxGeometry(16, 16, 16, 1, 1, 1);\n let wireGeo = new EdgesGeometry(boxGeo);\n let wireMat = new LineBasicMaterial({ color: color, linewidth: w, })\n let wireframe = new LineSegments(wireGeo, wireMat);\n obj.add(wireframe);\n\n let axes = new AxesHelper(1);\n obj.add(axes);\n}\n\n/** Adds edge and axis helpers to a mesh and returns a function that disposes their resources. */\nexport function addWireframeToMesh(geo: BufferGeometry, mesh: Mesh, color: number = 0xffffff, w: number = 2) {\n let wireGeo = new EdgesGeometry(geo);\n let wireMat = new LineBasicMaterial({ color: color, linewidth: w, })\n let wireframe = new LineSegments(wireGeo, wireMat);\n mesh.add(wireframe);\n\n let axes = new AxesHelper(1);\n mesh.add(axes);\n\n return () => {\n wireGeo.dispose();\n wireMat.dispose();\n axes.dispose();\n };\n}\n"],"mappings":";AAOA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,YAAkB,aAAa,eAAe,mBAAmB,cAAmD,eAAwB;AAW9I,SAAS,qBAAqB,UAA2B,UAA0B;AACtF,QAAM,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC;AAqCrF,WAAS,UAAU,CAAC,OAAO,GAAG,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC;AAElD,UAAQ,SAAS,MAAM;AAAA,IACnB,KAAK,KAAK;AACN,eAAS,QAAQ,UAAU,SAAS,KAAK,CAAC;AAC1C;AAAA,IACJ,KAAK,KAAK;AACN,eAAS,QAAQ,UAAU,SAAS,KAAK,CAAC;AAC1C;AAAA,IAC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IAAI;AAChB;AAGO,SAAS,qBAAqB,KAAe,QAAgB,UAAU,IAAY,GAAG;AACzF,MAAI,SAAS,IAAI,YAAY,IAAI,IAAI,IAAI,GAAG,GAAG,CAAC;AAChD,MAAI,UAAU,IAAI,cAAc,MAAM;AACtC,MAAI,UAAU,IAAI,kBAAkB,EAAE,OAAc,WAAW,EAAG,CAAC;AACnE,MAAI,YAAY,IAAI,aAAa,SAAS,OAAO;AACjD,MAAI,IAAI,SAAS;AAEjB,MAAI,OAAO,IAAI,WAAW,CAAC;AAC3B,MAAI,IAAI,IAAI;AAChB;AAGO,SAAS,mBAAmB,KAAqB,MAAY,QAAgB,UAAU,IAAY,GAAG;AACzG,MAAI,UAAU,IAAI,cAAc,GAAG;AACnC,MAAI,UAAU,IAAI,kBAAkB,EAAE,OAAc,WAAW,EAAG,CAAC;AACnE,MAAI,YAAY,IAAI,aAAa,SAAS,OAAO;AACjD,OAAK,IAAI,SAAS;AAElB,MAAI,OAAO,IAAI,WAAW,CAAC;AAC3B,OAAK,IAAI,IAAI;AAEb,SAAO,MAAM;AACT,YAAQ,QAAQ;AAChB,YAAQ,QAAQ;AAChB,SAAK,QAAQ;AAAA,EACjB;AACJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/util/model.ts"],"sourcesContent":["/// https://stackoverflow.com/questions/42812861/three-js-pivot-point/42866733#42866733\n// obj - your object (THREE.Object3D or derived)\n// point - the point of rotation (THREE.Vector3)\n// axis - the axis of rotation (normalized THREE.Vector3)\n// theta - radian value of rotation\nimport { ElementRotation } from \"../model/ModelElement\";\nimport type { BufferGeometry } from \"three\";\nimport { Axis } from \"../Axis\";\nimport { toRadians } from \"./util\";\nimport { AxesHelper, Box3, BoxGeometry, EdgesGeometry, LineBasicMaterial, LineSegments, Matrix4, Mesh, Object3D, Quaternion, Vector3, Vector4 } from \"three\";\n\nfunction rotateAboutPoint(obj: Object3D, point: Vector3, axis: Vector3, theta: number) {\n obj.position.sub(point); // remove the offset\n obj.position.applyAxisAngle(axis, theta); // rotate the POSITION\n obj.position.add(point); // re-add the offset\n\n obj.rotateOnAxis(axis, theta); // rotate the OBJECT\n}\n\n/** Rotates geometry in place around the element's origin. The supplied angle is in degrees. */\nexport function applyElementRotation(rotation: ElementRotation, geometry: BufferGeometry) {\n const origin = new Vector3(rotation.origin[0], rotation.origin[1], rotation.origin[2]);\n // origin.multiplyScalar(0.0625);\n\n\n // let axisVector: Vector3;\n // let inverseAxisVector: Vector3;\n // switch (rotation.axis) {\n // case Axis.X:\n // axisVector = new Vector3(1, 0, 0);\n // inverseAxisVector = new Vector3(0, 1, 1);\n // break;\n // case Axis.Y:\n // axisVector = new Vector3(0, 1, 0);\n // inverseAxisVector = new Vector3(1, 0, 1);\n // break;\n // case Axis.Z:\n // axisVector = new Vector3(0, 0, 1);\n // inverseAxisVector = new Vector3(1, 1, 0);\n // break;\n // }\n // const quat = new Quaternion().setFromAxisAngle(axisVector, (rotation.angle*0.017453292));\n // if (rotation.rescale) {\n // if (Math.abs(rotation.angle) === 22.5) {\n // inverseAxisVector.multiplyScalar(1.0 / Math.cos(0.39269909262657166) - 1.0)\n // }else {\n // inverseAxisVector.multiplyScalar(1.0 / Math.cos(0.7853981852531433) - 1.0)\n // }\n //\n // inverseAxisVector.add(new Vector3(1, 1, 1));\n // }else{\n // inverseAxisVector.set(1, 1, 1);\n // }\n\n // Vector4 vec4 = new Vector4(geometry.getAttribute(\"position\").)\n\n\n // subtract origin\n geometry.translate(-origin.x, -origin.y, -origin.z);\n // apply rotation\n switch (rotation.axis) {\n case Axis.X:\n geometry.rotateX(toRadians(rotation.angle));\n break;\n case Axis.Y:\n geometry.rotateY(toRadians(rotation.angle));\n break;\n case Axis.Z:\n geometry.rotateZ(toRadians(rotation.angle));\n break;\n }\n\n\n // if (rotation.rescale) {\n // console.log(\"angle\", Math.abs(rotation.angle) )\n // if (Math.abs(rotation.angle) === 22.5) {\n // const s = 2;\n // geometry.scale(s, s, s);\n // }else{\n // const s = 2;\n // geometry.scale(s, s, s);\n // }\n // }\n if (rotation.rescale) {\n // As in vanilla 1.21.6+, the element keeps its unrotated size along the nearest grid axis.\n const angle = toRadians(rotation.angle);\n const s = 1 / Math.max(Math.abs(Math.cos(angle)), Math.abs(Math.sin(angle)));\n geometry.scale(\n rotation.axis === Axis.X ? 1 : s,\n rotation.axis === Axis.Y ? 1 : s,\n rotation.axis === Axis.Z ? 1 : s\n );\n }\n\n // add back origin\n geometry.translate(origin.x, origin.y, origin.z);\n\n\n}\n\n/** Rotates an object around a local axis by an angle in degrees. */\nexport function applyGenericRotation(axis: Axis, rotation: number, obj: Object3D) {\n\n\n // obj.position.sub(new Vector3(8,8,8).add(obj.position))\n //\n // switch (axis) {\n // case Axis.X:\n // obj.position.applyAxisAngle(new Vector3(1, 0, 0), toRadians(rotation));\n // break;\n // case Axis.Y:\n // obj.position.applyAxisAngle(new Vector3(0, 1, 0), toRadians(rotation));\n // break;\n // case Axis.Z:\n // obj.position.applyAxisAngle(new Vector3(0, 0, 1), toRadians(rotation));\n // break;\n // }\n //\n // obj.position.add(new Vector3(8,8,8).add(obj.position))\n\n switch (axis) {\n case Axis.X:\n obj.rotateOnAxis(new Vector3(1, 0, 0), toRadians(rotation));\n break;\n case Axis.Y:\n obj.rotateOnAxis(new Vector3(0, 1, 0), toRadians(rotation));\n break;\n case Axis.Z:\n obj.rotateOnAxis(new Vector3(0, 0, 1), toRadians(rotation));\n break;\n }\n\n // subtract origin\n // obj.translateX(-8);\n // obj.translateZ(-8);\n // obj.translateY(-8);\n // // apply rotation\n // switch (axis) {\n // case Axis.X:\n // obj.rotateX(toRadians(rotation));\n // // matrix.makeRotationX(toRadians(rotation));\n // break;\n // case Axis.Y:\n // obj.rotateY(toRadians(rotation));\n // // matrix.makeRotationY(toRadians(rotation));\n // break;\n // case Axis.Z:\n // obj.rotateZ(toRadians(rotation));\n // // matrix.makeRotationZ(toRadians(rotation));\n // break;\n // }\n // // add back origin\n // obj.translateX(8);\n // obj.translateZ(8);\n // obj.translateY(8);\n\n // obj.applyMatrix4(matrix);\n}\n\nexport function addBox3WireframeToObject(box: Box3, obj: Object3D, color: number = 0xffffff, w: number = 2) {\n let size = new Vector3();\n box.getSize(size);\n\n let boxGeo = new BoxGeometry(size.x, size.y, size.z, 1, 1, 1);\n // boxGeo.translate(box.min.x, box.min.y, box.min.z);\n let wireGeo = new EdgesGeometry(boxGeo);\n let wireMat = new LineBasicMaterial({ color: color, linewidth: w, })\n let wireframe = new LineSegments(wireGeo, wireMat);\n obj.add(wireframe);\n\n let axes = new AxesHelper(1);\n obj.add(axes);\n}\n\n\nexport function addWireframeToObject(obj: Object3D, color: number = 0xffffff, w: number = 2) {\n let boxGeo = new BoxGeometry(16, 16, 16, 1, 1, 1);\n let wireGeo = new EdgesGeometry(boxGeo);\n let wireMat = new LineBasicMaterial({ color: color, linewidth: w, })\n let wireframe = new LineSegments(wireGeo, wireMat);\n obj.add(wireframe);\n\n let axes = new AxesHelper(1);\n obj.add(axes);\n}\n\n/** Adds edge and axis helpers to a mesh and returns a function that disposes their resources. */\nexport function addWireframeToMesh(geo: BufferGeometry, mesh: Mesh, color: number = 0xffffff, w: number = 2) {\n let wireGeo = new EdgesGeometry(geo);\n let wireMat = new LineBasicMaterial({ color: color, linewidth: w, })\n let wireframe = new LineSegments(wireGeo, wireMat);\n mesh.add(wireframe);\n\n let axes = new AxesHelper(1);\n mesh.add(axes);\n\n return () => {\n wireGeo.dispose();\n wireMat.dispose();\n axes.dispose();\n };\n}\n"],"mappings":";AAOA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,YAAkB,aAAa,eAAe,mBAAmB,cAAmD,eAAwB;AAW9I,SAAS,qBAAqB,UAA2B,UAA0B;AACtF,QAAM,SAAS,IAAI,QAAQ,SAAS,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC;AAqCrF,WAAS,UAAU,CAAC,OAAO,GAAG,CAAC,OAAO,GAAG,CAAC,OAA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AG,KAAK,GAAG,GAAG,GAAG,CAAC;AAE5D,MAAI,UAAU,IAAI,cAAc,MAAM;AACtC,MAAI,UAAU,IAAI,kBAAkB,EAAE,OAAc,WAAW,EAAG,CAAC;AACnE,MAAI,YAAY,IAAI,aAAa,SAAS,OAAO;AACjD,MAAI,IAAI,SAAS;AAEjB,MAAI,OAAO,IAAI,WAAW,CAAC;AAC3B,MAAI,IAAI,IAAI;AAChB;AAGO,SAAS,qBAAqB,KAAe,QAAgB,UAAU,IAAY,GAAG;AACzF,MAAI,SAAS,IAAI,YAAY,IAAI,IAAI,IAAI,GAAG,GAAG,CAAC;AAChD,MAAI,UAAU,IAAI,cAAc,MAAM;AACtC,MAAI,UAAU,IAAI,kBAAkB,EAAE,OAAc,WAAW,EAAG,CAAC;AACnE,MAAI,YAAY,IAAI,aAAa,SAAS,OAAO;AACjD,MAAI,IAAI,SAAS;AAEjB,MAAI,OAAO,IAAI,WAAW,CAAC;AAC3B,MAAI,IAAI,IAAI;AAChB;AAGO,SAAS,mBAAmB,KAAqB,MAAY,QAAgB,UAAU,IAAY,GAAG;AACzG,MAAI,UAAU,IAAI,cAAc,GAAG;AACnC,MAAI,UAAU,IAAI,kBAAkB,EAAE,OAAc,WAAW,EAAG,CAAC;AACnE,MAAI,YAAY,IAAI,aAAa,SAAS,OAAO;AACjD,OAAK,IAAI,SAAS;AAElB,MAAI,OAAO,IAAI,WAAW,CAAC;AAC3B,OAAK,IAAI,IAAI;AAEb,SAAO,MAAM;AACT,YAAQ,QAAQ;AAChB,YAAQ,QAAQ;AAChB,SAAK,QAAQ;AAAA,EACjB;AACJ;","names":[]}
@@ -2631,13 +2631,13 @@ function applyElementRotation(rotation, geometry) {
2631
2631
  break;
2632
2632
  }
2633
2633
  if (rotation.rescale) {
2634
- if (Math.abs(rotation.angle) === 22.5) {
2635
- const s = 1 / Math.cos(0.39269909262657166);
2636
- geometry.scale(s, 1, s);
2637
- } else {
2638
- const s = 1 / Math.cos(0.7853981852531433);
2639
- geometry.scale(s, 1, s);
2640
- }
2634
+ const angle = toRadians(rotation.angle);
2635
+ const s = 1 / Math.max(Math.abs(Math.cos(angle)), Math.abs(Math.sin(angle)));
2636
+ geometry.scale(
2637
+ rotation.axis === "x" /* X */ ? 1 : s,
2638
+ rotation.axis === "y" /* Y */ ? 1 : s,
2639
+ rotation.axis === "z" /* Z */ ? 1 : s
2640
+ );
2641
2641
  }
2642
2642
  geometry.translate(origin.x, origin.y, origin.z);
2643
2643
  }