@hology/core 0.0.31 → 0.0.33

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.
Files changed (138) hide show
  1. package/dist/csm.d.ts +1 -1
  2. package/dist/csm.js +1 -1
  3. package/dist/effects/vfx/index.d.ts +2 -2
  4. package/dist/effects/vfx/index.js +1 -1
  5. package/dist/effects/vfx/initializsers.d.ts +14 -7
  6. package/dist/effects/vfx/initializsers.js +1 -1
  7. package/dist/effects/vfx/vfx-actor.d.ts +2 -2
  8. package/dist/effects/vfx/vfx-actor.js +1 -1
  9. package/dist/effects/vfx/vfx-asset.d.ts +3 -3
  10. package/dist/effects/vfx/vfx-asset.js +1 -1
  11. package/dist/effects/vfx/vfx-defs.d.ts +5 -2
  12. package/dist/effects/vfx/vfx-defs.js +1 -1
  13. package/dist/effects/vfx/vfx-materializer.d.ts +2 -1
  14. package/dist/effects/vfx/vfx-materializer.js +1 -1
  15. package/dist/effects/vfx/vfx-param.d.ts +1 -1
  16. package/dist/gameplay/actors/actor.d.ts +1 -1
  17. package/dist/gameplay/actors/actor.js +1 -1
  18. package/dist/gameplay/actors/builtin/camera-actor.d.ts +3 -3
  19. package/dist/gameplay/actors/builtin/camera-actor.js +1 -1
  20. package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -3
  21. package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
  22. package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts +4 -4
  23. package/dist/gameplay/actors/builtin/components/character/character-movement copy.js +1 -1
  24. package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +4 -4
  25. package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
  26. package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +2 -2
  27. package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
  28. package/dist/gameplay/actors/builtin/components/scene-component.d.ts +1 -1
  29. package/dist/gameplay/actors/builtin/components/scene-component.js +1 -1
  30. package/dist/gameplay/actors/builtin/index.d.ts +4 -4
  31. package/dist/gameplay/actors/builtin/index.js +1 -1
  32. package/dist/gameplay/actors/builtin/positional-audio-actor.d.ts +6 -5
  33. package/dist/gameplay/actors/builtin/positional-audio-actor.js +1 -1
  34. package/dist/gameplay/actors/builtin/spawn-point.d.ts +3 -3
  35. package/dist/gameplay/actors/builtin/spawn-point.js +1 -1
  36. package/dist/gameplay/actors/builtin/trigger-volume.d.ts +4 -4
  37. package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
  38. package/dist/gameplay/actors/camera/camera-component.d.ts +2 -2
  39. package/dist/gameplay/actors/camera/camera-component.js +1 -1
  40. package/dist/gameplay/actors/camera/third-party-camera-component.d.ts +5 -5
  41. package/dist/gameplay/actors/camera/third-party-camera-component.js +1 -1
  42. package/dist/gameplay/actors/component.d.ts +1 -1
  43. package/dist/gameplay/actors/component.js +1 -1
  44. package/dist/gameplay/actors/factory.d.ts +3 -3
  45. package/dist/gameplay/actors/factory.js +1 -1
  46. package/dist/gameplay/actors/index.d.ts +10 -10
  47. package/dist/gameplay/actors/index.js +1 -1
  48. package/dist/gameplay/actors/internal/component-init.d.ts +2 -2
  49. package/dist/gameplay/actors/internal/component-init.js +1 -1
  50. package/dist/gameplay/actors/internal/container-map.d.ts +1 -1
  51. package/dist/gameplay/animation/anim-sm.js +1 -1
  52. package/dist/gameplay/index.d.ts +14 -13
  53. package/dist/gameplay/index.js +1 -1
  54. package/dist/gameplay/initiate.d.ts +4 -2
  55. package/dist/gameplay/initiate.js +1 -1
  56. package/dist/gameplay/inject.js +1 -1
  57. package/dist/gameplay/input/index.d.ts +3 -3
  58. package/dist/gameplay/input/index.js +1 -1
  59. package/dist/gameplay/input/input-service.d.ts +1 -1
  60. package/dist/gameplay/input/input-service.js +1 -1
  61. package/dist/gameplay/input/input.js +1 -1
  62. package/dist/gameplay/services/asset-loader.d.ts +6 -4
  63. package/dist/gameplay/services/asset-loader.js +1 -1
  64. package/dist/gameplay/services/physics/physics-system.d.ts +5 -5
  65. package/dist/gameplay/services/physics/physics-system.js +1 -1
  66. package/dist/gameplay/services/pointer-events.d.ts +58 -0
  67. package/dist/gameplay/services/pointer-events.js +5 -0
  68. package/dist/gameplay/services/render.d.ts +3 -3
  69. package/dist/gameplay/services/render.js +1 -1
  70. package/dist/gameplay/services/world.d.ts +5 -2
  71. package/dist/gameplay/services/world.js +1 -1
  72. package/dist/index.d.ts +4 -4
  73. package/dist/index.js +1 -1
  74. package/dist/rendering.d.ts +7 -1
  75. package/dist/rendering.js +1 -1
  76. package/dist/scene/asset-resource-loader.d.ts +2 -2
  77. package/dist/scene/asset-resource-loader.js +1 -1
  78. package/dist/scene/assets-provider.d.ts +1 -1
  79. package/dist/scene/bootstrap.d.ts +7 -7
  80. package/dist/scene/bootstrap.js +1 -1
  81. package/dist/scene/collision/collision-shape-import.d.ts +1 -1
  82. package/dist/scene/collision/collision-shape-import.js +1 -1
  83. package/dist/scene/landscape/landscape-manager.d.ts +6 -6
  84. package/dist/scene/landscape/landscape-manager.js +1 -1
  85. package/dist/scene/landscape/landscape.js +1 -1
  86. package/dist/scene/landscape/utils.d.ts +1 -1
  87. package/dist/scene/landscape/utils.js +1 -1
  88. package/dist/scene/materializer.d.ts +10 -10
  89. package/dist/scene/materializer.js +1 -1
  90. package/dist/scene/materials/grass-foliage.d.ts +2 -2
  91. package/dist/scene/materials/grass-foliage.js +1 -1
  92. package/dist/scene/materials/grass.d.ts +1 -1
  93. package/dist/scene/materials/grass.js +1 -1
  94. package/dist/scene/materials/water.d.ts +1 -1
  95. package/dist/scene/materials/water.js +1 -1
  96. package/dist/scene/model.d.ts +6 -5
  97. package/dist/scene/objects/shapes.d.ts +3 -3
  98. package/dist/scene/objects/shapes.js +1 -1
  99. package/dist/scene/runtime-asset-service.d.ts +3 -3
  100. package/dist/scene/runtime-asset-service.js +1 -1
  101. package/dist/scene/runtime-backend-service.d.ts +1 -1
  102. package/dist/scene/runtime-backend-service.js +1 -1
  103. package/dist/scene/scene-data-service.d.ts +1 -1
  104. package/dist/scene/scene-data-service.js +1 -1
  105. package/dist/scene/storage/storage.js +1 -1
  106. package/dist/shader/builtin/index.d.ts +2 -2
  107. package/dist/shader/builtin/index.js +1 -1
  108. package/dist/shader/builtin/lambert-shader.d.ts +1 -1
  109. package/dist/shader/builtin/lambert-shader.js +1 -1
  110. package/dist/shader/builtin/standard-shader.d.ts +1 -1
  111. package/dist/shader/builtin/standard-shader.js +1 -1
  112. package/dist/shader/index.d.ts +3 -2
  113. package/dist/shader/index.js +1 -1
  114. package/dist/shader/parameter.d.ts +4 -4
  115. package/dist/shader/parameter.js +1 -1
  116. package/dist/shader/shader.d.ts +4 -4
  117. package/dist/shader/shader.js +1 -1
  118. package/dist/shader-nodes/effects.js +1 -1
  119. package/dist/shader-nodes/index.d.ts +9 -9
  120. package/dist/shader-nodes/index.js +1 -1
  121. package/dist/shader-nodes/layers.js +1 -1
  122. package/dist/test/injection.test.js +1 -1
  123. package/dist/utils/collections.js +1 -1
  124. package/dist/utils/three/depth-pass.js +1 -1
  125. package/dist/utils/three/outline-pass.d.ts +2 -2
  126. package/dist/utils/three/transform-controls.d.ts +2 -2
  127. package/dist/utils/three/traverse.d.ts +1 -0
  128. package/dist/utils/three/traverse.js +1 -1
  129. package/package.json +7 -8
  130. package/tsconfig.tsbuildinfo +1 -1
  131. package/dist/utils/cannon/CannonUtils.d.ts +0 -17
  132. package/dist/utils/cannon/CannonUtils.js +0 -5
  133. package/dist/utils/cannon/three-to-cannon/ConvexHull.d.ts +0 -47
  134. package/dist/utils/cannon/three-to-cannon/ConvexHull.js +0 -5
  135. package/dist/utils/cannon/three-to-cannon/index.d.ts +0 -63
  136. package/dist/utils/cannon/three-to-cannon/index.js +0 -5
  137. package/dist/utils/cannon/three-to-cannon/utils.d.ts +0 -9
  138. package/dist/utils/cannon/three-to-cannon/utils.js +0 -5
@@ -1,17 +0,0 @@
1
- import * as THREE from "three";
2
- import * as CANNON from "cannon-es";
3
- import { Vector3 } from "three";
4
- declare class CannonUtils {
5
- static Three2Cannon(): {
6
- vector3: ({ x, y, z }: THREE.Vector3) => CANNON.Vec3;
7
- quaternion: ({ x, y, z, w }: THREE.Quaternion) => CANNON.Quaternion;
8
- };
9
- static Cannon2Three(): {
10
- vector3: ({ x, y, z }: CANNON.Vec3) => THREE.Vector3;
11
- quaternion: ({ x, y, z, w }: CANNON.Quaternion) => THREE.Quaternion;
12
- };
13
- static CreateTrimesh(geometry: THREE.BufferGeometry, scale: Vector3): CANNON.Trimesh;
14
- static CreateConvexPolyhedron(geometry: THREE.BufferGeometry): CANNON.ConvexPolyhedron;
15
- static offsetCenterOfMass(body: CANNON.Body, centreOfMass: CANNON.Vec3): void;
16
- }
17
- export default CannonUtils;
@@ -1,5 +0,0 @@
1
- import*as t from"three";import*as e from"cannon-es";export default class{static Three2Cannon(){return{vector3:({x:t,y:n,z:o})=>new e.Vec3(t,n,o),quaternion:({x:t,y:n,z:o,w:r})=>new e.Quaternion(t,n,o,r)}}static Cannon2Three(){return{vector3:({x:e,y:n,z:o})=>new t.Vector3(e,n,o),quaternion:({x:e,y:n,z:o,w:r})=>new t.Quaternion(e,n,o,r)}}static CreateTrimesh(t,n){let o;o=null===t.index?t.attributes.position.array:t.clone().toNonIndexed().attributes.position.array;for(let t=0;t<o.length;t+=3)o[t]*=n.x,o[t+1]*=n.y,o[t+2]*=n.z;const r=Object.keys(o).map(Number);return new e.Trimesh(o,r)}static CreateConvexPolyhedron(n){const o=n.attributes.position,r=n.attributes.normal,s=[];for(let e=0;e<o.count;e++)s.push((new t.Vector3).fromBufferAttribute(o,e));const a=[];for(let e=0;e<o.count;e+=3){const n={a:e,b:e+1,c:e+2,normals:void 0===r?[]:[(new t.Vector3).fromBufferAttribute(r,e),(new t.Vector3).fromBufferAttribute(r,e+1),(new t.Vector3).fromBufferAttribute(r,e+2)]};a.push(n)}const c={},i=[],u=[];for(let t=0,n=s.length;t<n;t++){const n=s[t],o=Math.round(100*n.x)+"_"+Math.round(100*n.y)+"_"+Math.round(100*n.z);void 0===c[o]?(c[o]=t,i.push(new e.Vec3(s[t].x,s[t].y,s[t].z)),u[t]=i.length-1):u[t]=u[c[o]]}const f=[];for(let t=0,e=a.length;t<e;t++){const e=a[t];e.a=u[e.a],e.b=u[e.b],e.c=u[e.c];const n=[e.a,e.b,e.c];for(let e=0;e<3;e++)if(n[e]===n[(e+1)%3]){f.push(t);break}}for(let t=f.length-1;t>=0;t--){const e=f[t];a.splice(e,1)}const l=a.map((function(t){return[t.a,t.b,t.c]}));return new e.ConvexPolyhedron({vertices:i,faces:l})}static offsetCenterOfMass(t,n){t.shapeOffsets.forEach((function(t){n.vadd(t,n)})),n.scale(1/t.shapes.length,n),t.shapeOffsets.forEach((function(t){t.vsub(n,t)}));const o=new e.Vec3;t.vectorToWorldFrame(n,o),t.position.vadd(o,t.position)}}
2
- /*
3
- * Copyright (©) 2023. All rights reserved.
4
- * See the LICENSE.md file for details.
5
- */
@@ -1,47 +0,0 @@
1
- export declare class ConvexHull {
2
- tolerance: number;
3
- faces: any[];
4
- newFaces: any[];
5
- assigned: VertexList;
6
- unassigned: VertexList;
7
- vertices: any[];
8
- setFromPoints(points: any): this;
9
- setFromObject(object: any): this;
10
- containsPoint(point: any): boolean;
11
- intersectRay(ray: any, target: any): any;
12
- intersectsRay(ray: any): boolean;
13
- makeEmpty(): this;
14
- addVertexToFace(vertex: any, face: any): this;
15
- removeVertexFromFace(vertex: any, face: any): this;
16
- removeAllVerticesFromFace(face: any): any;
17
- deleteFaceVertices(face: any, absorbingFace?: any): this;
18
- resolveUnassignedPoints(newFaces: any): this;
19
- computeExtremes(): {
20
- min: any[];
21
- max: any[];
22
- };
23
- computeInitialHull(): this;
24
- reindexFaces(): this;
25
- nextVertexToAdd(): any;
26
- computeHorizon(eyePoint: any, crossEdge: any, face: any, horizon: any): this;
27
- addAdjoiningFace(eyeVertex: any, horizonEdge: any): any;
28
- addNewFaces(eyeVertex: any, horizon: any): this;
29
- addVertexToHull(eyeVertex: any): this;
30
- cleanup(): this;
31
- compute(): this;
32
- }
33
- declare class VertexList {
34
- head: any;
35
- tail: any;
36
- first(): any;
37
- last(): any;
38
- clear(): this;
39
- insertBefore(target: any, vertex: any): this;
40
- insertAfter(target: any, vertex: any): this;
41
- append(vertex: any): this;
42
- appendChain(vertex: any): this;
43
- remove(vertex: any): this;
44
- removeSubList(a: any, b: any): this;
45
- isEmpty(): boolean;
46
- }
47
- export {};
@@ -1,5 +0,0 @@
1
- import{Line3 as t,Plane as e,Triangle as i,Vector3 as n}from"three";var s=new n;export class ConvexHull{constructor(){this.tolerance=-1,this.faces=[],this.newFaces=[],this.assigned=new h,this.unassigned=new h,this.vertices=[]}setFromPoints(t){!0!==Array.isArray(t)&&console.error("THREE.ConvexHull: Points parameter is not an array."),t.length<4&&console.error("THREE.ConvexHull: The algorithm needs at least four points."),this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.vertices.push(new o(t[e]));return this.compute(),this}setFromObject(t){var e=[];return t.updateMatrixWorld(!0),t.traverse((function(t){var i,s,r,a=t.geometry;if(void 0!==a&&a.isBufferGeometry){var o=a.attributes.position;if(void 0!==o)for(i=0,s=o.count;i<s;i++)(r=new n).fromBufferAttribute(o,i).applyMatrix4(t.matrixWorld),e.push(r)}})),this.setFromPoints(e)}containsPoint(t){for(var e=this.faces,i=0,n=e.length;i<n;i++){if(e[i].distanceToPoint(t)>this.tolerance)return!1}return!0}intersectRay(t,e){for(var i=this.faces,n=-1/0,s=1/0,r=0,a=i.length;r<a;r++){var o=i[r],h=o.distanceToPoint(t.origin),l=o.normal.dot(t.direction);if(h>0&&l>=0)return null;var u=0!==l?-h/l:0;if(!(u<=0)&&(l>0?s=Math.min(u,s):n=Math.max(u,n),n>s))return null}return n!==-1/0?t.at(n,e):t.at(s,e),e}intersectsRay(t){return null!==this.intersectRay(t,s)}makeEmpty(){return this.faces=[],this.vertices=[],this}addVertexToFace(t,e){return t.face=e,null===e.outside?this.assigned.append(t):this.assigned.insertBefore(e.outside,t),e.outside=t,this}removeVertexFromFace(t,e){return t===e.outside&&(null!==t.next&&t.next.face===e?e.outside=t.next:e.outside=null),this.assigned.remove(t),this}removeAllVerticesFromFace(t){if(null!==t.outside){for(var e=t.outside,i=t.outside;null!==i.next&&i.next.face===t;)i=i.next;return this.assigned.removeSubList(e,i),e.prev=i.next=null,t.outside=null,e}}deleteFaceVertices(t,e){var i=this.removeAllVerticesFromFace(t);if(void 0!==i)if(void 0===e)this.unassigned.appendChain(i);else{var n=i;do{var s=n.next;e.distanceToPoint(n.point)>this.tolerance?this.addVertexToFace(n,e):this.unassigned.append(n),n=s}while(null!==n)}return this}resolveUnassignedPoints(t){if(!1===this.unassigned.isEmpty()){var e=this.unassigned.first();do{for(var i=e.next,n=this.tolerance,s=null,r=0;r<t.length;r++){var a=t[r];if(0===a.mark){var o=a.distanceToPoint(e.point);if(o>n&&(n=o,s=a),n>1e3*this.tolerance)break}}null!==s&&this.addVertexToFace(e,s),e=i}while(null!==e)}return this}computeExtremes(){var t,e,i,s=new n,r=new n,a=[],o=[];for(t=0;t<3;t++)a[t]=o[t]=this.vertices[0];for(s.copy(this.vertices[0].point),r.copy(this.vertices[0].point),t=0,e=this.vertices.length;t<e;t++){var h=this.vertices[t],l=h.point;for(i=0;i<3;i++)l.getComponent(i)<s.getComponent(i)&&(s.setComponent(i,l.getComponent(i)),a[i]=h);for(i=0;i<3;i++)l.getComponent(i)>r.getComponent(i)&&(r.setComponent(i,l.getComponent(i)),o[i]=h)}return this.tolerance=3*Number.EPSILON*(Math.max(Math.abs(s.x),Math.abs(r.x))+Math.max(Math.abs(s.y),Math.abs(r.y))+Math.max(Math.abs(s.z),Math.abs(r.z))),{min:a,max:o}}computeInitialHull(){var i,s,a;void 0===i&&(i=new t,s=new e,a=new n);var o,h,l,u,c,d,p,v,f,m=this.vertices,g=this.computeExtremes(),x=g.min,w=g.max,T=0,F=0;for(d=0;d<3;d++)(f=w[d].point.getComponent(d)-x[d].point.getComponent(d))>T&&(T=f,F=d);for(h=x[F],l=w[F],T=0,i.set(h.point,l.point),d=0,p=this.vertices.length;d<p;d++)(o=m[d])!==h&&o!==l&&(i.closestPointToPoint(o.point,!0,a),(f=a.distanceToSquared(o.point))>T&&(T=f,u=o));for(T=-1,s.setFromCoplanarPoints(h.point,l.point,u.point),d=0,p=this.vertices.length;d<p;d++)(o=m[d])!==h&&o!==l&&o!==u&&(f=Math.abs(s.distanceToPoint(o.point)))>T&&(T=f,c=o);var E=[];if(s.distanceToPoint(c.point)<0)for(E.push(r.create(h,l,u),r.create(c,l,h),r.create(c,u,l),r.create(c,h,u)),d=0;d<3;d++)v=(d+1)%3,E[d+1].getEdge(2).setTwin(E[0].getEdge(v)),E[d+1].getEdge(1).setTwin(E[v+1].getEdge(0));else for(E.push(r.create(h,u,l),r.create(c,h,l),r.create(c,l,u),r.create(c,u,h)),d=0;d<3;d++)v=(d+1)%3,E[d+1].getEdge(2).setTwin(E[0].getEdge((3-d)%3)),E[d+1].getEdge(0).setTwin(E[v+1].getEdge(1));for(d=0;d<4;d++)this.faces.push(E[d]);for(d=0,p=m.length;d<p;d++)if((o=m[d])!==h&&o!==l&&o!==u&&o!==c){T=this.tolerance;var P=null;for(v=0;v<4;v++)(f=this.faces[v].distanceToPoint(o.point))>T&&(T=f,P=this.faces[v]);null!==P&&this.addVertexToFace(o,P)}return this}reindexFaces(){for(var t=[],e=0;e<this.faces.length;e++){var i=this.faces[e];0===i.mark&&t.push(i)}return this.faces=t,this}nextVertexToAdd(){if(!1===this.assigned.isEmpty()){var t,e=0,i=this.assigned.first().face,n=i.outside;do{var s=i.distanceToPoint(n.point);s>e&&(e=s,t=n),n=n.next}while(null!==n&&n.face===i);return t}}computeHorizon(t,e,i,n){var s;this.deleteFaceVertices(i),i.mark=1,s=null===e?e=i.getEdge(0):e.next;do{var r=s.twin,a=r.face;0===a.mark&&(a.distanceToPoint(t)>this.tolerance?this.computeHorizon(t,r,a,n):n.push(s)),s=s.next}while(s!==e);return this}addAdjoiningFace(t,e){var i=r.create(t,e.tail(),e.head());return this.faces.push(i),i.getEdge(-1).setTwin(e.twin),i.getEdge(0)}addNewFaces(t,e){this.newFaces=[];for(var i=null,n=null,s=0;s<e.length;s++){var r=e[s],a=this.addAdjoiningFace(t,r);null===i?i=a:a.next.setTwin(n),this.newFaces.push(a.face),n=a}return i.next.setTwin(n),this}addVertexToHull(t){var e=[];return this.unassigned.clear(),this.removeVertexFromFace(t,t.face),this.computeHorizon(t.point,null,t.face,e),this.addNewFaces(t,e),this.resolveUnassignedPoints(this.newFaces),this}cleanup(){return this.assigned.clear(),this.unassigned.clear(),this.newFaces=[],this}compute(){var t;for(this.computeInitialHull();void 0!==(t=this.nextVertexToAdd());)this.addVertexToHull(t);return this.reindexFaces(),this.cleanup(),this}}class r{constructor(){this.normal=new n,this.midpoint=new n,this.area=0,this.constant=0,this.outside=null,this.mark=0,this.edge=null}getEdge(t){for(var e=this.edge;t>0;)e=e.next,t--;for(;t<0;)e=e.prev,t++;return e}compute(){var t;void 0===t&&(t=new i);var e=this.edge.tail(),n=this.edge.head(),s=this.edge.next.head();return t.set(e.point,n.point,s.point),t.getNormal(this.normal),t.getMidpoint(this.midpoint),this.area=t.getArea(),this.constant=this.normal.dot(this.midpoint),this}distanceToPoint(t){return this.normal.dot(t)-this.constant}static create(t,e,i){var n=new r,s=new a(t,n),o=new a(e,n),h=new a(i,n);return s.next=h.prev=o,o.next=s.prev=h,h.next=o.prev=s,n.edge=s,n.compute()}}function a(t,e){this.vertex=t,this.prev=null,this.next=null,this.twin=null,this.face=e}function o(t){this.point=t,this.prev=null,this.next=null,this.face=null}Object.assign(a.prototype,{head:function(){return this.vertex},tail:function(){return this.prev?this.prev.vertex:null},length:function(){var t=this.head(),e=this.tail();return null!==e?e.point.distanceTo(t.point):-1},lengthSquared:function(){var t=this.head(),e=this.tail();return null!==e?e.point.distanceToSquared(t.point):-1},setTwin:function(t){return this.twin=t,t.twin=this,this}});class h{constructor(){this.head=null,this.tail=null}first(){return this.head}last(){return this.tail}clear(){return this.head=this.tail=null,this}insertBefore(t,e){return e.prev=t.prev,e.next=t,null===e.prev?this.head=e:e.prev.next=e,t.prev=e,this}insertAfter(t,e){return e.prev=t,e.next=t.next,null===e.next?this.tail=e:e.next.prev=e,t.next=e,this}append(t){return null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail,t.next=null,this.tail=t,this}appendChain(t){for(null===this.head?this.head=t:this.tail.next=t,t.prev=this.tail;null!==t.next;)t=t.next;return this.tail=t,this}remove(t){return null===t.prev?this.head=t.next:t.prev.next=t.next,null===t.next?this.tail=t.prev:t.next.prev=t.prev,this}removeSubList(t,e){return null===t.prev?this.head=e.next:t.prev.next=e.next,null===e.next?this.tail=t.prev:e.next.prev=t.prev,this}isEmpty(){return null===this.head}}
2
- /*
3
- * Copyright (©) 2023. All rights reserved.
4
- * See the LICENSE.md file for details.
5
- */
@@ -1,63 +0,0 @@
1
- import { Quaternion as CQuaternion, Shape, Vec3 } from 'cannon-es';
2
- import { Object3D } from 'three';
3
- export type BoxParameters = {
4
- x: number;
5
- y: number;
6
- z: number;
7
- };
8
- export type CylinderParameters = {
9
- radiusTop: number;
10
- radiusBottom: number;
11
- height: number;
12
- segments: number;
13
- };
14
- export type SphereParameters = {
15
- radius: number;
16
- };
17
- export type ConvexPolyhedronParameters = {
18
- vertices: Float32Array;
19
- faces: number[][];
20
- };
21
- export type TrimeshParameters = {
22
- vertices: Float32Array;
23
- indices: Uint32Array;
24
- };
25
- type ShapeTypeToShapeParameters = {
26
- Box: BoxParameters;
27
- Cylinder: CylinderParameters;
28
- Sphere: SphereParameters;
29
- ConvexPolyhedron: ConvexPolyhedronParameters;
30
- Trimesh: TrimeshParameters;
31
- };
32
- export declare enum ShapeType {
33
- BOX = "Box",
34
- CYLINDER = "Cylinder",
35
- SPHERE = "Sphere",
36
- HULL = "ConvexPolyhedron",
37
- MESH = "Trimesh"
38
- }
39
- export interface ShapeOptions {
40
- type?: ShapeType;
41
- cylinderAxis?: 'x' | 'y' | 'z';
42
- sphereRadius?: number;
43
- }
44
- export interface ShapeParameters<T extends ShapeType = ShapeType> {
45
- type: T;
46
- params: ShapeTypeToShapeParameters[T];
47
- offset?: Vec3;
48
- orientation?: CQuaternion;
49
- }
50
- export interface ShapeResult<T extends Shape = Shape> {
51
- shape: T;
52
- offset?: Vec3;
53
- orientation?: CQuaternion;
54
- }
55
- /**
56
- * Given a THREE.Object3D instance, creates parameters for a CANNON shape.
57
- */
58
- export declare const getShapeParameters: (object: Object3D, options?: ShapeOptions) => ShapeParameters | null;
59
- /**
60
- * Given a THREE.Object3D instance, creates a corresponding CANNON shape.
61
- */
62
- export declare const threeToCannon: (object: Object3D, options?: ShapeOptions) => ShapeResult | null;
63
- export {};
@@ -1,5 +0,0 @@
1
- import{Box as e,Quaternion as t,ConvexPolyhedron as n,Cylinder as r,Sphere as o,Trimesh as a,Vec3 as i}from"cannon-es";import{Box3 as s,MathUtils as p,Mesh as u,Vector3 as m}from"three";import{ConvexHull as c}from"./ConvexHull";import{getComponent as y,getGeometry as h,getVertices as f}from"./utils";const l=Math.PI/2;export var ShapeType;!function(e){e.BOX="Box",e.CYLINDER="Cylinder",e.SPHERE="Sphere",e.HULL="ConvexPolyhedron",e.MESH="Trimesh"}(ShapeType||(ShapeType={}));export const getShapeParameters=function(e,n={}){let r;if(n.type===ShapeType.BOX)return S(e);if(n.type===ShapeType.CYLINDER)return function(e,n){const r=["x","y","z"],o=n.cylinderAxis||"y",a=r.splice(r.indexOf(o),1)&&r,i=(new s).setFromObject(e);if(!isFinite(i.min.lengthSq()))return null;const p=i.max[o]-i.min[o],u=.5*Math.max(y(i.max,a[0])-y(i.min,a[0]),y(i.max,a[1])-y(i.min,a[1])),m="y"===o?l:0,c="z"===o?l:0;return{type:ShapeType.CYLINDER,params:{radiusTop:u,radiusBottom:u,height:p,segments:12},orientation:(new t).setFromEuler(m,c,0,"XYZ").normalize()}}(e,n);if(n.type===ShapeType.SPHERE)return function(e,t){if(t.sphereRadius)return{type:ShapeType.SPHERE,params:{radius:t.sphereRadius}};const n=h(e);return n?(n.computeBoundingSphere(),{type:ShapeType.SPHERE,params:{radius:n.boundingSphere.radius}}):null}(e,n);if(n.type===ShapeType.HULL)return function(e){const t=h(e);if(!t)return null;const n=1e-4;for(let e=0;e<t.attributes.position.count;e++)t.attributes.position.setXYZ(e,t.attributes.position.getX(e)+(Math.random()-.5)*n,t.attributes.position.getY(e)+(Math.random()-.5)*n,t.attributes.position.getZ(e)+(Math.random()-.5)*n);const r=(new c).setFromObject(new u(t)),o=r.faces,a=[],i=[];let s=0;for(let e=0;e<o.length;e++){const t=o[e],n=[];i.push(n);let r=t.edge;do{const e=r.head().point;a.push(e.x,e.y,e.z),n.push(s),s++,r=r.next}while(r!==t.edge)}const p=new Float32Array(a.length);return p.set(a),{type:ShapeType.HULL,params:{vertices:p,faces:i}}}(e);if(n.type===ShapeType.MESH)return r=h(e),r?function(e){const t=f(e);if(!t.length)return null;const n=new Uint32Array(t.length);for(let e=0;e<t.length;e++)n[e]=e;return{type:ShapeType.MESH,params:{vertices:t,indices:n}}}(r):null;if(n.type)throw new Error(`[CANNON.getShapeParameters] Invalid type "${n.type}".`);if(r=h(e),!r)return null;switch(r.type){case"BoxGeometry":case"BoxBufferGeometry":return d(r);case"CylinderGeometry":case"CylinderBufferGeometry":return function(e){const n=e.parameters;return{type:ShapeType.CYLINDER,params:{radiusTop:n.radiusTop,radiusBottom:n.radiusBottom,height:n.height,segments:n.radialSegments},orientation:(new t).setFromEuler(p.degToRad(-90),0,0,"XYZ").normalize()}}(r);case"PlaneGeometry":case"PlaneBufferGeometry":return function(e){e.computeBoundingBox();const t=e.boundingBox;return{type:ShapeType.BOX,params:{x:(t.max.x-t.min.x)/2||.1,y:(t.max.y-t.min.y)/2||.1,z:(t.max.z-t.min.z)/2||.1}}}(r);case"SphereGeometry":case"SphereBufferGeometry":return function(e){return{type:ShapeType.SPHERE,params:{radius:e.parameters.radius}}}(r);case"TubeGeometry":case"BufferGeometry":return S(e);default:return console.warn('Unrecognized geometry: "%s". Using bounding box as shape.',r.type),d(r)}};export const threeToCannon=function(t,s={}){const p=getShapeParameters(t,s);if(!p)return null;const{type:u,params:m,offset:c,orientation:y}=p;let h;return h=u===ShapeType.BOX?function(t){const{x:n,y:r,z:o}=t,a=new e(new i(n,r,o));return a}(m):u===ShapeType.CYLINDER?function(e){const{radiusTop:t,radiusBottom:n,height:o,segments:a}=e,i=new r(t,n,o,a);return i.radiusTop=n,i.radiusBottom=n,i.height=o,i.numSegments=a,i}(m):u===ShapeType.SPHERE?function(e){const t=new o(e.radius);return t}(m):u===ShapeType.HULL?function(e){const{faces:t,vertices:r}=e,o=[];for(let e=0;e<r.length;e+=3)o.push(new i(r[e],r[e+1],r[e+2]));const a=new n({faces:t,vertices:o});return a}(m):function(e){const{vertices:t,indices:n}=e,r=new a(t,n);return r}(m),{shape:h,offset:c,orientation:y}};function d(e){if(!f(e).length)return null;e.computeBoundingBox();const t=e.boundingBox;return{type:ShapeType.BOX,params:{x:(t.max.x-t.min.x)/2,y:(t.max.y-t.min.y)/2,z:(t.max.z-t.min.z)/2}}}function S(e){const t=e.clone();t.quaternion.set(0,0,0,1),t.updateMatrixWorld();const n=(new s).setFromObject(t);if(!isFinite(n.min.lengthSq()))return null;const r=n.translate(t.position.negate()).getCenter(new m);return{type:ShapeType.BOX,params:{x:(n.max.x-n.min.x)/2,y:(n.max.y-n.min.y)/2,z:(n.max.z-n.min.z)/2},offset:r.lengthSq()?new i(r.x,r.y,r.z):void 0}}
2
- /*
3
- * Copyright (©) 2023. All rights reserved.
4
- * See the LICENSE.md file for details.
5
- */
@@ -1,9 +0,0 @@
1
- import { BufferGeometry, Object3D, Vector3 } from 'three';
2
- /**
3
- * Returns a single geometry for the given object. If the object is compound,
4
- * its geometries are automatically merged. Bake world scale into each
5
- * geometry, because we can't easily apply that to the cannonjs shapes later.
6
- */
7
- export declare function getGeometry(object: Object3D): BufferGeometry | null;
8
- export declare function getVertices(geometry: BufferGeometry): Float32Array;
9
- export declare function getComponent(v: Vector3, component: string): number;
@@ -1,5 +0,0 @@
1
- import{BufferAttribute as t,BufferGeometry as e,Quaternion as n,Vector3 as o}from"three";const r=new o,i=new o,u=new n;export function getGeometry(n){const o=function(t){const e=[];return t.traverse((function(t){t.isMesh&&e.push(t)})),e}(n);if(0===o.length)return null;if(1===o.length)return s(o[0]);let r;const i=[];for(;r=o.pop();)i.push(c(s(r)));return function(n){let o=0;for(let t=0;t<n.length;t++){const e=n[t].attributes.position;e&&3===e.itemSize&&(o+=e.count)}const r=new Float32Array(3*o);let i=0;for(let t=0;t<n.length;t++){const e=n[t].attributes.position;if(e&&3===e.itemSize)for(let t=0;t<e.count;t++)r[i++]=e.getX(t),r[i++]=e.getY(t),r[i++]=e.getZ(t)}return(new e).setAttribute("position",new t(r,3))}(i)}function s(t){let e=t.geometry;return e=e.toBufferGeometry?e.toBufferGeometry():e.clone(),t.updateMatrixWorld(),t.matrixWorld.decompose(r,u,i),e.scale(i.x,i.y,i.z),e}export function getVertices(t){const e=t.attributes.position,n=new Float32Array(3*e.count);for(let t=0;t<e.count;t++)n[3*t]=e.getX(t),n[3*t+1]=e.getY(t),n[3*t+2]=e.getZ(t);return n}export function getComponent(t,e){switch(e){case"x":return t.x;case"y":return t.y;case"z":return t.z}throw new Error(`Unexpected component ${e}`)}function c(n,o=1e-4){o=Math.max(o,Number.EPSILON);const r={},i=n.getIndex(),u=n.getAttribute("position"),s=i?i.count:u.count;let c=0;const l=[],p=[],g=Math.log10(1/o),a=Math.pow(10,g);for(let t=0;t<s;t++){const e=i?i.getX(t):t;let n="";n+=~~(u.getX(e)*a)+",",n+=~~(u.getY(e)*a)+",",n+=~~(u.getZ(e)*a)+",",n in r?l.push(r[n]):(p.push(u.getX(e)),p.push(u.getY(e)),p.push(u.getZ(e)),r[n]=c,l.push(c),c++)}const f=new t(new Float32Array(p),u.itemSize,u.normalized),h=new e;return h.setAttribute("position",f),h.setIndex(l),h}
2
- /*
3
- * Copyright (©) 2023. All rights reserved.
4
- * See the LICENSE.md file for details.
5
- */