@hology/core 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. package/LICENSE.md +15 -0
  2. package/README.md +3 -0
  3. package/dist/config/project-config.d.ts +10 -0
  4. package/dist/config/project-config.js +5 -0
  5. package/dist/controllers/base-game-controller.d.ts +3 -0
  6. package/dist/controllers/base-game-controller.js +5 -0
  7. package/dist/csm.d.ts +7 -0
  8. package/dist/csm.js +5 -0
  9. package/dist/effects/particles/examples.d.ts +271 -0
  10. package/dist/effects/particles/examples.js +5 -0
  11. package/dist/effects/particles/particle-system-config.d.ts +85 -0
  12. package/dist/effects/particles/particle-system-config.js +5 -0
  13. package/dist/game-component/component-decorators.d.ts +5 -0
  14. package/dist/game-component/component-decorators.js +5 -0
  15. package/dist/game-component/game-component.d.ts +8 -0
  16. package/dist/game-component/game-component.js +5 -0
  17. package/dist/gameplay/actors/actor.d.ts +37 -0
  18. package/dist/gameplay/actors/actor.js +5 -0
  19. package/dist/gameplay/actors/builtin/camera-actor.d.ts +11 -0
  20. package/dist/gameplay/actors/builtin/camera-actor.js +5 -0
  21. package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +67 -0
  22. package/dist/gameplay/actors/builtin/components/character/character-animation.js +5 -0
  23. package/dist/gameplay/actors/builtin/components/character/character-movement copy.d.ts +37 -0
  24. package/dist/gameplay/actors/builtin/components/character/character-movement copy.js +5 -0
  25. package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +51 -0
  26. package/dist/gameplay/actors/builtin/components/character/character-movement.js +5 -0
  27. package/dist/gameplay/actors/builtin/components/character/modes.d.ts +18 -0
  28. package/dist/gameplay/actors/builtin/components/character/modes.js +5 -0
  29. package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +20 -0
  30. package/dist/gameplay/actors/builtin/components/mesh-component.js +5 -0
  31. package/dist/gameplay/actors/builtin/components/scene-component.d.ts +7 -0
  32. package/dist/gameplay/actors/builtin/components/scene-component.js +5 -0
  33. package/dist/gameplay/actors/builtin/index.d.ts +11 -0
  34. package/dist/gameplay/actors/builtin/index.js +5 -0
  35. package/dist/gameplay/actors/builtin/positional-audio-actor.d.ts +19 -0
  36. package/dist/gameplay/actors/builtin/positional-audio-actor.js +5 -0
  37. package/dist/gameplay/actors/builtin/spawn-point.d.ts +11 -0
  38. package/dist/gameplay/actors/builtin/spawn-point.js +5 -0
  39. package/dist/gameplay/actors/builtin/trigger-volume.d.ts +23 -0
  40. package/dist/gameplay/actors/builtin/trigger-volume.js +5 -0
  41. package/dist/gameplay/actors/camera/camera-component.d.ts +13 -0
  42. package/dist/gameplay/actors/camera/camera-component.js +5 -0
  43. package/dist/gameplay/actors/camera/third-party-camera-component.d.ts +43 -0
  44. package/dist/gameplay/actors/camera/third-party-camera-component.js +5 -0
  45. package/dist/gameplay/actors/component.d.ts +41 -0
  46. package/dist/gameplay/actors/component.js +5 -0
  47. package/dist/gameplay/actors/factory.d.ts +12 -0
  48. package/dist/gameplay/actors/factory.js +5 -0
  49. package/dist/gameplay/actors/index.d.ts +10 -0
  50. package/dist/gameplay/actors/index.js +5 -0
  51. package/dist/gameplay/actors/internal/component-init.d.ts +3 -0
  52. package/dist/gameplay/actors/internal/component-init.js +5 -0
  53. package/dist/gameplay/actors/internal/container-map.d.ts +6 -0
  54. package/dist/gameplay/actors/internal/container-map.js +5 -0
  55. package/dist/gameplay/animation/anim-sm.d.ts +38 -0
  56. package/dist/gameplay/animation/anim-sm.js +5 -0
  57. package/dist/gameplay/animation/root-motion.d.ts +31 -0
  58. package/dist/gameplay/animation/root-motion.js +5 -0
  59. package/dist/gameplay/env.d.ts +3 -0
  60. package/dist/gameplay/env.js +5 -0
  61. package/dist/gameplay/index.d.ts +14 -0
  62. package/dist/gameplay/index.js +5 -0
  63. package/dist/gameplay/initiate.d.ts +51 -0
  64. package/dist/gameplay/initiate.js +5 -0
  65. package/dist/gameplay/inject.d.ts +3 -0
  66. package/dist/gameplay/inject.js +5 -0
  67. package/dist/gameplay/input/index.d.ts +3 -0
  68. package/dist/gameplay/input/index.js +5 -0
  69. package/dist/gameplay/input/input-service.d.ts +33 -0
  70. package/dist/gameplay/input/input-service.js +5 -0
  71. package/dist/gameplay/input/input.d.ts +41 -0
  72. package/dist/gameplay/input/input.js +5 -0
  73. package/dist/gameplay/input/keybind.d.ts +23 -0
  74. package/dist/gameplay/input/keybind.js +5 -0
  75. package/dist/gameplay/services/asset-loader.d.ts +34 -0
  76. package/dist/gameplay/services/asset-loader.js +5 -0
  77. package/dist/gameplay/services/physics/collision-contact.d.ts +2 -0
  78. package/dist/gameplay/services/physics/collision-contact.js +5 -0
  79. package/dist/gameplay/services/physics/physics-system.d.ts +145 -0
  80. package/dist/gameplay/services/physics/physics-system.js +5 -0
  81. package/dist/gameplay/services/render.d.ts +19 -0
  82. package/dist/gameplay/services/render.js +5 -0
  83. package/dist/gameplay/services/world.d.ts +15 -0
  84. package/dist/gameplay/services/world.js +5 -0
  85. package/dist/index.d.ts +4 -0
  86. package/dist/index.js +5 -0
  87. package/dist/rendering/shader-override.d.ts +2 -0
  88. package/dist/rendering/shader-override.js +5 -0
  89. package/dist/rendering.d.ts +53 -0
  90. package/dist/rendering.js +5 -0
  91. package/dist/scene/asset-resource-loader.d.ts +32 -0
  92. package/dist/scene/asset-resource-loader.js +5 -0
  93. package/dist/scene/assets-provider.d.ts +9 -0
  94. package/dist/scene/assets-provider.js +5 -0
  95. package/dist/scene/bootstrap.d.ts +21 -0
  96. package/dist/scene/bootstrap.js +5 -0
  97. package/dist/scene/collision/collision-shape-import.d.ts +4 -0
  98. package/dist/scene/collision/collision-shape-import.js +5 -0
  99. package/dist/scene/collision/collision-shape.d.ts +59 -0
  100. package/dist/scene/collision/collision-shape.js +5 -0
  101. package/dist/scene/landscape/landscape-manager.d.ts +43 -0
  102. package/dist/scene/landscape/landscape-manager.js +5 -0
  103. package/dist/scene/landscape/landscape.d.ts +20 -0
  104. package/dist/scene/landscape/landscape.js +5 -0
  105. package/dist/scene/landscape/utils.d.ts +9 -0
  106. package/dist/scene/landscape/utils.js +5 -0
  107. package/dist/scene/materializer.d.ts +245 -0
  108. package/dist/scene/materializer.js +5 -0
  109. package/dist/scene/materials/grass-foliage.d.ts +8 -0
  110. package/dist/scene/materials/grass-foliage.js +5 -0
  111. package/dist/scene/materials/grass.d.ts +4 -0
  112. package/dist/scene/materials/grass.js +5 -0
  113. package/dist/scene/materials/utils/material-painting.d.ts +2 -0
  114. package/dist/scene/materials/utils/material-painting.js +5 -0
  115. package/dist/scene/materials/utils/noise.glsl.d.ts +1 -0
  116. package/dist/scene/materials/utils/noise.glsl.js +5 -0
  117. package/dist/scene/materials/water.d.ts +3 -0
  118. package/dist/scene/materials/water.js +5 -0
  119. package/dist/scene/model.d.ts +96 -0
  120. package/dist/scene/model.js +5 -0
  121. package/dist/scene/objects/ramp-geometry.d.ts +2 -0
  122. package/dist/scene/objects/ramp-geometry.js +5 -0
  123. package/dist/scene/objects/shapes.d.ts +121 -0
  124. package/dist/scene/objects/shapes.js +5 -0
  125. package/dist/scene/runtime-asset-service.d.ts +14 -0
  126. package/dist/scene/runtime-asset-service.js +5 -0
  127. package/dist/scene/runtime-backend-service.d.ts +12 -0
  128. package/dist/scene/runtime-backend-service.js +5 -0
  129. package/dist/scene/scene-data-service.d.ts +33 -0
  130. package/dist/scene/scene-data-service.js +5 -0
  131. package/dist/scene/sky.d.ts +3 -0
  132. package/dist/scene/sky.js +5 -0
  133. package/dist/scene/storage/storage.d.ts +39 -0
  134. package/dist/scene/storage/storage.js +5 -0
  135. package/dist/shader/builtin/index.d.ts +2 -0
  136. package/dist/shader/builtin/index.js +5 -0
  137. package/dist/shader/builtin/lambert-shader.d.ts +19 -0
  138. package/dist/shader/builtin/lambert-shader.js +5 -0
  139. package/dist/shader/builtin/standard-shader.d.ts +29 -0
  140. package/dist/shader/builtin/standard-shader.js +5 -0
  141. package/dist/shader/index.d.ts +2 -0
  142. package/dist/shader/index.js +5 -0
  143. package/dist/shader/parameter.d.ts +23 -0
  144. package/dist/shader/parameter.js +5 -0
  145. package/dist/shader/shader.d.ts +25 -0
  146. package/dist/shader/shader.js +5 -0
  147. package/dist/shader-nodes/depth.d.ts +10 -0
  148. package/dist/shader-nodes/depth.js +5 -0
  149. package/dist/shader-nodes/index.d.ts +5 -0
  150. package/dist/shader-nodes/index.js +5 -0
  151. package/dist/shader-nodes/landscape.d.ts +5 -0
  152. package/dist/shader-nodes/landscape.js +5 -0
  153. package/dist/shader-nodes/layers.d.ts +14 -0
  154. package/dist/shader-nodes/layers.js +5 -0
  155. package/dist/shader-nodes/time.d.ts +4 -0
  156. package/dist/shader-nodes/time.js +5 -0
  157. package/dist/test/injection.test.d.ts +1 -0
  158. package/dist/test/injection.test.js +5 -0
  159. package/dist/utils/async.d.ts +5 -0
  160. package/dist/utils/async.js +5 -0
  161. package/dist/utils/cannon/CannonUtils.d.ts +17 -0
  162. package/dist/utils/cannon/CannonUtils.js +5 -0
  163. package/dist/utils/cannon/three-to-cannon/ConvexHull.d.ts +47 -0
  164. package/dist/utils/cannon/three-to-cannon/ConvexHull.js +5 -0
  165. package/dist/utils/cannon/three-to-cannon/index.d.ts +63 -0
  166. package/dist/utils/cannon/three-to-cannon/index.js +5 -0
  167. package/dist/utils/cannon/three-to-cannon/utils.d.ts +9 -0
  168. package/dist/utils/cannon/three-to-cannon/utils.js +5 -0
  169. package/dist/utils/collections.d.ts +26 -0
  170. package/dist/utils/collections.js +5 -0
  171. package/dist/utils/files.d.ts +1 -0
  172. package/dist/utils/files.js +5 -0
  173. package/dist/utils/math.d.ts +24 -0
  174. package/dist/utils/math.js +5 -0
  175. package/dist/utils/mesh.d.ts +6 -0
  176. package/dist/utils/mesh.js +5 -0
  177. package/dist/utils/polyfill.d.ts +1 -0
  178. package/dist/utils/polyfill.js +5 -0
  179. package/dist/utils/three/depth-pass.d.ts +13 -0
  180. package/dist/utils/three/depth-pass.js +5 -0
  181. package/dist/utils/three/line-sphere.d.ts +2 -0
  182. package/dist/utils/three/line-sphere.js +5 -0
  183. package/dist/utils/three/outline-pass.d.ts +61 -0
  184. package/dist/utils/three/outline-pass.js +5 -0
  185. package/dist/utils/three/positional-audio-helper.d.ts +11 -0
  186. package/dist/utils/three/positional-audio-helper.js +5 -0
  187. package/dist/utils/three/stats.d.ts +12 -0
  188. package/dist/utils/three/stats.js +5 -0
  189. package/dist/utils/three/transform-controls.d.ts +73 -0
  190. package/dist/utils/three/transform-controls.js +5 -0
  191. package/dist/utils/three/traverse.d.ts +13 -0
  192. package/dist/utils/three/traverse.js +5 -0
  193. package/dist/utils/type.d.ts +4 -0
  194. package/dist/utils/type.js +5 -0
  195. package/dist/utils/uuid.d.ts +1 -0
  196. package/dist/utils/uuid.js +5 -0
  197. package/package.json +114 -0
  198. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,29 @@
1
+ import { Color, Material, Texture, Vector2 } from 'three';
2
+ import { Shader } from "../shader";
3
+ export declare class StandardShader extends Shader {
4
+ color: Color;
5
+ roughness?: number;
6
+ metalness?: number;
7
+ map?: Texture;
8
+ lightMap?: Texture;
9
+ lightMapIntensity?: number;
10
+ aoMap?: Texture;
11
+ aoMapIntensity?: number;
12
+ emissive?: Color;
13
+ emissiveIntensity?: number;
14
+ emissiveMap?: Texture;
15
+ bumpMap?: Texture;
16
+ bumpScale?: number;
17
+ normalMap?: Texture;
18
+ normalScale?: Vector2;
19
+ displacementMap?: Texture;
20
+ displacementScale?: number;
21
+ displacementBias?: number;
22
+ roughnessMap?: Texture;
23
+ metalnessMap?: Texture;
24
+ alphaMap?: Texture;
25
+ envMap?: Texture;
26
+ envMapIntensity?: number;
27
+ refractionRatio?: number;
28
+ build(): Material;
29
+ }
@@ -0,0 +1,5 @@
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Color as a,MeshStandardMaterial as p,Texture as d,Vector2 as i}from"three";import{Shader as r}from"../shader";import{Parameter as s}from"../parameter";import{removeObjectUndefined as n}from"../../utils/collections";export class StandardShader extends r{build(){return new p(n({color:this.color,roughness:this.roughness,metalness:this.metalness,map:this.map,lightMap:this.lightMap,lightMapIntensity:this.lightMapIntensity,aoMap:this.aoMap,aoMapIntensity:this.aoMapIntensity,emissive:this.emissive,emissiveIntensity:this.emissiveIntensity,emissiveMap:this.emissiveMap,bumpMap:this.bumpMap,bumpScale:this.bumpScale,normalMap:this.normalMap,normalScale:this.normalScale,displacementMap:this.displacementMap,displacementScale:this.displacementScale,displacementBias:this.displacementBias,roughnessMap:this.roughnessMap,metalnessMap:this.metalnessMap,alphaMap:this.alphaMap,envMap:this.envMap,envMapIntensity:this.envMapIntensity,refractionRatio:this.refractionRatio}))}}e([s(),t("design:type",a)],StandardShader.prototype,"color",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"roughness",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"metalness",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"map",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"lightMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"lightMapIntensity",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"aoMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"aoMapIntensity",void 0),e([s(),t("design:type",a)],StandardShader.prototype,"emissive",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"emissiveIntensity",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"emissiveMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"bumpMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"bumpScale",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"normalMap",void 0),e([s(),t("design:type",i)],StandardShader.prototype,"normalScale",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"displacementMap",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"displacementScale",void 0),e([s(),t("design:type",Number)],StandardShader.prototype,"displacementBias",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"roughnessMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"metalnessMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"alphaMap",void 0),e([s(),t("design:type",d)],StandardShader.prototype,"envMap",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"envMapIntensity",void 0),e([s({range:[0,1]}),t("design:type",Number)],StandardShader.prototype,"refractionRatio",void 0);
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,2 @@
1
+ export * from './parameter';
2
+ export * from './builtin';
@@ -0,0 +1,5 @@
1
+ export*from"./parameter";export*from"./builtin";
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,23 @@
1
+ import 'reflect-metadata';
2
+ import { Type } from '../utils/type';
3
+ import { BaseActor } from '../gameplay/actors/actor';
4
+ import { Color, Euler, Material, Mesh, Texture, Vector2, Vector3, Vector4 } from 'three';
5
+ import { BooleanNode, FloatNode, RgbNode, Sampler2DNode, Vec2Node, Vec3Node, Vec4Node } from '../shader-nodes';
6
+ export type ParameterType = Type<FloatNode | Number | Texture | Sampler2DNode | Boolean | BooleanNode | Vector2 | Vec2Node | Vector3 | Vec3Node | Vector4 | Vec4Node | Color | RgbNode | String | BaseActor | Euler | Mesh | Material>;
7
+ export type ParameterOption<T> = {
8
+ name: string;
9
+ value: T;
10
+ };
11
+ export interface ParameterOptions {
12
+ range?: [number, number];
13
+ precision?: number;
14
+ type?: ParameterType;
15
+ options?: ParameterOption<unknown>[];
16
+ }
17
+ export interface PropertyParameter {
18
+ name: string;
19
+ type: ParameterType;
20
+ options: ParameterOptions;
21
+ }
22
+ export declare function Parameter(options?: ParameterOptions): (target: Object, propertyName: string | symbol, index?: unknown) => void;
23
+ export declare function extractShaderParameters(shaderType: Type<any>): PropertyParameter[];
@@ -0,0 +1,5 @@
1
+ import"reflect-metadata";import t,{decorateProperty as e}from"@plumier/reflect";import{ArrayMap as o}from"../utils/collections";Symbol("format");class r{constructor(t){this.options=t,this.isParameterDecorator=!0}}const n=new o;export function Parameter(t){return function(o,a,c){if(null!=o){n.push(o.constructor,{name:a,options:null!=t?t:{}});try{e(new r(t))(o,a,c)}catch(t){console.warn("Failed to decorate method ",o,a,c)}}}}export function extractShaderParameters(t){return n.get(t).map((({name:e,options:o})=>({name:e,type:Reflect.getMetadata("design:type",t.prototype,e),options:o})))}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,25 @@
1
+ import { BaseActor } from "../gameplay";
2
+ import { Material } from "three";
3
+ import { RgbaNode, Mat4Node } from "../shader-nodes";
4
+ import { Type } from "../utils/type";
5
+ export * from './parameter';
6
+ export declare abstract class Shader {
7
+ abstract build(): Material;
8
+ }
9
+ export type ShaderType = Type<Shader>;
10
+ export type ActorType = Type<BaseActor>;
11
+ export type ClassImpl<T> = {
12
+ name: string;
13
+ type: Type<T>;
14
+ };
15
+ export type ActorImpl = ClassImpl<BaseActor>;
16
+ export type ShaderImpl = ClassImpl<Shader>;
17
+ export type NodeShaderOutput = {
18
+ color: RgbaNode;
19
+ transform?: Mat4Node;
20
+ transparent?: boolean;
21
+ };
22
+ export declare abstract class NodeShader {
23
+ build(): Material;
24
+ abstract output(): NodeShaderOutput;
25
+ }
@@ -0,0 +1,5 @@
1
+ import{NodeShaderMaterial as r}from"../shader-nodes";export*from"./parameter";export class Shader{}export class NodeShader{build(){return new r(Object.assign({transparent:!0},this.output()))}}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,10 @@
1
+ import { WebGLRenderer } from 'three';
2
+ import { FloatNode } from 'three-shader-graph';
3
+ export declare function supportsDepthTextureExtension(renderer: WebGLRenderer): boolean;
4
+ export declare const depthUniformName = "hology_depth_map";
5
+ export declare const resolutionUniformName = "hology_resolution";
6
+ export declare const nearUniformName = "hology_camera_near";
7
+ export declare const farUniformName = "hology_camera_far";
8
+ export declare const depthSampler: import("three-shader-graph").UniformSampler2d;
9
+ export declare const fragmentLinearEyeDepth: FloatNode;
10
+ export declare const linearEyeDepth: FloatNode;
@@ -0,0 +1,5 @@
1
+ import{Vector2 as e}from"three";import{dot as t,FloatExpressionNode as o,FloatNode as r,texture2d as n,uniformVec2 as s,Vec2ExpressionNode as a,Vec4Node as c,uniformSampler2d as p,uniformFloat as i}from"three-shader-graph";export function supportsDepthTextureExtension(e){return!!e.extensions.get("WEBGL_depth_texture")}export const depthUniformName="hology_depth_map";export const resolutionUniformName="hology_resolution";export const nearUniformName="hology_camera_near";export const farUniformName="hology_camera_far";export const depthSampler=p(depthUniformName);const h=i(nearUniformName,.5),m=i(farUniformName,500);class l extends r{compile(e){const t=e.variable();var o=e.get(h),r=e.get(m);return{chunk:`\n float depth_${t} = 2.0 * ${o} * ${r} / (${r} + ${o} - (2.0 * ${e.get(this.depth)} - 1.0) * (${r} - ${o}));\n `,out:`depth_${t}`}}constructor(e){super(),this.depth=e}}function u(e){return new l(e)}const _=new class extends c{constructor(){super(...arguments),this.k="31u50"}compile(e){return{pars:`\n const float UnpackDownscale_${this.k} = 255. / 256.; // 0..1 -> fraction (excluding 1)\n const vec3 PackFactors_${this.k} = vec3( 256. * 256. * 256., 256. * 256., 256. );\n const vec4 UnpackFactors_${this.k} = UnpackDownscale_${this.k} / vec4( PackFactors_${this.k}, 1. );\n `,out:`UnpackFactors_${this.k}`}}};const d=new o("gl_FragCoord.z");export const fragmentLinearEyeDepth=u(d);const f=s("hology_resolution",new e(250,1e3)),g=new a("gl_FragCoord.xy").divide(f);export const linearEyeDepth=u((x=g,$=n(depthSampler,x),t($,_)));var x,$;
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,5 @@
1
+ export * from 'three-shader-graph';
2
+ export { linearEyeDepth, fragmentLinearEyeDepth, depthSampler } from './depth';
3
+ export { timeUniforms } from './time';
4
+ export * from './layers';
5
+ export * from './landscape';
@@ -0,0 +1,5 @@
1
+ export*from"three-shader-graph";export{linearEyeDepth,fragmentLinearEyeDepth,depthSampler}from"./depth";export{timeUniforms}from"./time";export*from"./layers";export*from"./landscape";
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,5 @@
1
+ import { FloatNode } from 'three-shader-graph';
2
+ /**
3
+ * Get coordinates in world space which can be much better for texturing landscapes than using UV
4
+ */
5
+ export declare function getLandscapeCoords(scale: FloatNode | number): import("three-shader-graph").VaryingVec2Node;
@@ -0,0 +1,5 @@
1
+ import{attributes as r,float as t,uniforms as o,vec4 as e,varyingVec2 as a}from"three-shader-graph";const i=o.modelMatrix.multiplyVec(e(r.position,1));export function getLandscapeCoords(r){return a(i.xz().multiplyScalar(t(r)))}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,14 @@
1
+ import { RgbNode, RgbaNode, FloatNode } from "three-shader-graph";
2
+ export declare enum LayerMixMode {
3
+ hard = 0,
4
+ soft = 1
5
+ }
6
+ export interface MixColorsOptions<T extends RgbNode | RgbaNode> {
7
+ layerColors: T[];
8
+ enableNoise?: boolean;
9
+ noiseScale?: number | FloatNode;
10
+ noiseAmount?: number | FloatNode;
11
+ decay?: number | FloatNode;
12
+ mode?: LayerMixMode;
13
+ }
14
+ export declare function mixColorsByLayer<T extends RgbNode | RgbaNode>(options: MixColorsOptions<T>): T;
@@ -0,0 +1,5 @@
1
+ import{float as e,uniforms as o,vec4 as r,attributes as t,varyingVec2 as a,AttributeVec3Node as i,varyingVec3 as l,SimplexNoiseNode as d,select as s,mix as n,smoothstep as c}from"three-shader-graph";export var LayerMixMode;!function(e){e[e.hard=0]="hard",e[e.soft=1]="soft"}(LayerMixMode||(LayerMixMode={}));const y={enableNoise:!0,noiseScale:e(.1),noiseAmount:e(.5),decay:.3,mode:LayerMixMode.soft},u=a(o.modelMatrix.multiplyVec(r(t.position,1)).xz()),m=l(new i("material")),p=[e(0),m.x(),m.y(),m.z()];export function mixColorsByLayer(o){const r=Object.assign(Object.assign({},y),o),t=e(r.noiseAmount).multiply(e(.1)),a=e(r.noiseScale),i=new d(u.multiplyScalar(a)).multiply(e(2)).subtract(e(1)).multiply(t),l=e(.5),m=r.enableNoise?l.add(i.multiply(e(.1))):l;if(r.mode==LayerMixMode.hard)return r.layerColors.reduce(((e,o,r)=>s(p[r].gt(m),o,e)));{const o=e(r.decay),t=e(.5),a=o.divide(e(2)),l=t.subtract(a),d=t.add(a);return r.layerColors.slice(0,p.length).reduce(((e,o,r)=>n(e,o,c(l,d,p[r].add(i)))))}}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,4 @@
1
+ export declare const elapsedTimeUniformName = "hology_elapsed_time";
2
+ export declare const timeUniforms: {
3
+ elapsed: import("three-shader-graph").UniformFloatNode;
4
+ };
@@ -0,0 +1,5 @@
1
+ import{uniformFloat as e}from"three-shader-graph";export const elapsedTimeUniformName="hology_elapsed_time";export const timeUniforms={elapsed:e("hology_elapsed_time")};
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1 @@
1
+ import "reflect-metadata";
@@ -0,0 +1,5 @@
1
+ import{__awaiter as t,__decorate as e}from"tslib";import"reflect-metadata";import{expect as o,test as s}from"vitest";import{Actor as a,ActorComponent as n,ActorFactory as i,BaseActor as c,Component as r,inject as l}from"../gameplay";import u,{Service as m}from"typedi";s("injecting without a service decorator",(()=>{class t{}const e=u.of("test");e.set({id:t,type:t});e.get(t)})),s("creating actors with non default container instance",(()=>t(void 0,void 0,void 0,(function*(){const t=new i(u.of("custom"),{inEditor:!1});u.set(i,t);const e=yield t.create(y);o(e.componentA.a.value).toBe(e.a.value),o(u.of("another").get(p).value).toBeGreaterThan(e.a.value)})))),s("injection with dynamically attached component using same container",(()=>t(void 0,void 0,void 0,(function*(){const t=new i(u.of("custom2"),{inEditor:!1});u.set(i,t);const e=yield t.create(g);o(e.componentA.a.value).toBe(e.a.value)}))));let d=class{};d=e([m()],d);let h=0,p=class{constructor(){this.name="a",this.value=h++,this.b=l(v)}};p=e([m()],p);let v=class{constructor(){this.name="b",this.value=h++}};v=e([m()],v);let f=class extends n{constructor(){super(...arguments),this.a=l(p)}};f=e([r()],f);let y=class extends c{constructor(){super(...arguments),this.a=l(p),this.componentA=this.attach(f)}};y=e([a()],y);let g=class extends c{constructor(){super(...arguments),this.a=l(p)}onInit(){this.componentA=this.attach(f)}};g=e([a()],g);
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,5 @@
1
+ export declare function sleepDelay(ms: any): Promise<unknown>;
2
+ /**
3
+ * Executes a function whenever there is CPU available
4
+ */
5
+ export declare function whenIdle<T>(fn: () => T): Promise<T>;
@@ -0,0 +1,5 @@
1
+ export function sleepDelay(e){return new Promise((t=>setTimeout(t,e)))}export function whenIdle(e){return new Promise(((t,n)=>{window.requestIdleCallback((()=>{t(e())}),{timeout:500})}))}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,17 @@
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;
@@ -0,0 +1,5 @@
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
+ */
@@ -0,0 +1,47 @@
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 {};
@@ -0,0 +1,5 @@
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
+ */
@@ -0,0 +1,63 @@
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 {};
@@ -0,0 +1,5 @@
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
+ */
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,5 @@
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
+ */
@@ -0,0 +1,26 @@
1
+ export declare function groupBy<T, K>(a: T[], key: (v: T) => K): Map<K, T[]>;
2
+ export declare function indexBy<T, K>(a: T[], key: (v: T) => K): Map<K, T>;
3
+ export declare class DefaultMap<K, V> implements Map<K, V> {
4
+ private defaultValue;
5
+ private map;
6
+ constructor(defaultValue: V | (() => V));
7
+ clear(): void;
8
+ delete(key: K): boolean;
9
+ forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
10
+ private getDefault;
11
+ get(key: K): V;
12
+ has(key: K): boolean;
13
+ set(key: K, value: V): this;
14
+ size: number;
15
+ entries(): IterableIterator<[K, V]>;
16
+ keys(): IterableIterator<K>;
17
+ values(): IterableIterator<V>;
18
+ [Symbol.iterator](): IterableIterator<[K, V]>;
19
+ [Symbol.toStringTag]: string;
20
+ }
21
+ export declare class ArrayMap<K, V> extends DefaultMap<K, V[]> {
22
+ constructor();
23
+ push(key: K, value: V): void;
24
+ }
25
+ export declare function partition<T>(objects: T[], predicate: (o: T) => boolean): T[][];
26
+ export declare function removeObjectUndefined<T>(o: Record<string, T>): Record<string, T>;
@@ -0,0 +1,5 @@
1
+ export function groupBy(t,e){const r=new Map;for(const s of null!=t?t:[]){const t=e(s);r.has(t)||r.set(t,[]),r.get(t).push(s)}return r}export function indexBy(t,e){const r=new Map;for(const s of null!=t?t:[])r.set(e(s),s);return r}export class DefaultMap{constructor(t){this.defaultValue=t,this.map=new Map}clear(){this.map.clear()}delete(t){return this.map.delete(t)}forEach(t,e){this.map.forEach(t)}getDefault(){return"function"==typeof this.defaultValue?this.defaultValue():JSON.parse(JSON.stringify(this.defaultValue))}get(t){return this.map.has(t)||this.map.set(t,this.getDefault()),this.map.get(t)}has(t){return!0}set(t,e){return this.map.set(t,e),this}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}[Symbol.iterator](){return this.map[Symbol.iterator]()}}Symbol.toStringTag;export class ArrayMap extends DefaultMap{constructor(){super((()=>[]))}push(t,e){this.get(t).push(e)}}export function partition(t,e){let r=[],s=[];for(const a of t)(e(a)?r:s).push(a);return[r,s]}export function removeObjectUndefined(t){for(const e of Object.keys(t))null==t[e]&&delete t[e];return t}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1 @@
1
+ export declare function pathJoin(...args: String[]): string;
@@ -0,0 +1,5 @@
1
+ export function pathJoin(...e){return e.map(((e,r)=>0===r?e.trim().replace(/[\/]*$/g,""):e.trim().replace(/(^[\/]*|[\/]*$)/g,""))).filter((e=>e.length)).join("/")}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,24 @@
1
+ import * as THREE from 'three';
2
+ import { Vector3 } from 'three';
3
+ export declare function clamp(value: number, min: number, max: number): number;
4
+ /**
5
+ * Execute the function randomly.
6
+ * It is appropriate for making the game less repetitive.
7
+ * It should not be used for gameplay that affects state but instead just for special effects.
8
+ * @param chance
9
+ * @param f
10
+ */
11
+ export declare function byChance(chance: any, f: any): void;
12
+ export declare function mean(numbers: number[]): number;
13
+ export declare function meanVectors3(vectors: Vector3[]): THREE.Vector3;
14
+ export declare function meanBottomVectors3(vectors: Vector3[]): THREE.Vector3;
15
+ /**
16
+ * Avoid creating additional vectors
17
+ * For example when calculating the mean of many object's world positions you could
18
+ * do that without first having to store the world position of every object in separate vectors
19
+ */
20
+ export declare function meanVectors3Mapped<O>(vectors: O[], mapper: (obj: O, target: Vector3) => Vector3): THREE.Vector3;
21
+ export declare function meanVectors3withWeight(vectors: Vector3[], weights: number[], target: Vector3): THREE.Vector3;
22
+ export declare function randomString(length?: number): string;
23
+ export declare function toDegrees(radians: any): number;
24
+ export declare function boundingRadius(...objects: THREE.Object3D[]): number;
@@ -0,0 +1,5 @@
1
+ import*as t from"three";import{Vector3 as n}from"three";export function clamp(t,n,e){return Math.max(Math.min(e,t),n)}export function byChance(t,n){Math.random()<t&&n()}export function mean(t){let n=0,e=t.length;for(;--e>=0;)n+=t[e];return t.length>0?n/t.length:0}export function meanVectors3(t){const e=new n;for(const n of t)e.add(n);return e.divideScalar(t.length),e}export function meanBottomVectors3(t){const e=new n;let o=null;for(const n of t)e.add(n),(null==o||n.y<o)&&(o=n.y);return e.divideScalar(t.length),e.y=o,e}export function meanVectors3Mapped(t,e){const o=new n,r=new n;for(const n of t)r.add(e(n,o));return r.divideScalar(t.length),r}const e=new n;export function meanVectors3withWeight(t,n,o){let r=0;for(const t of n)r+=t;e.set(0,0,0);let a=0;for(const o of t){const t=n[a]/r;e.x+=o.x*t,e.y+=o.y*t,e.z+=o.z*t,a++}return o.copy(e),o}export function randomString(t=9){return Math.random().toString(36).substr(2,t)}export function toDegrees(t){return t*(180/Math.PI)}var o=new t.Sphere;export function boundingRadius(...n){o.makeEmpty();for(var e=0;e<n.length;e++)n[e].traverse((n=>{n instanceof t.Mesh&&(n.geometry.computeBoundingSphere(),o.union(n.geometry.boundingSphere))}));return o.radius}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,6 @@
1
+ import * as THREE from 'three';
2
+ import { Object3D } from 'three';
3
+ export declare class NoRaycastMesh extends THREE.Mesh {
4
+ raycast(...args: any[]): void;
5
+ }
6
+ export declare function cloneMesh<T extends Object3D>(o: T): T;
@@ -0,0 +1,5 @@
1
+ import*as e from"three";import{SkeletonUtils as t}from"three-stdlib";export class NoRaycastMesh extends e.Mesh{raycast(...e){}}export function cloneMesh(e){return t.clone(e)}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1 @@
1
+ export declare function polyfill(): void;
@@ -0,0 +1,5 @@
1
+ import*as e from"three";import{computeBoundsTree as o,disposeBoundsTree as r,acceleratedRaycast as t}from"three-mesh-bvh";export function polyfill(){e.BufferGeometry.prototype.computeBoundsTree=o,e.BufferGeometry.prototype.disposeBoundsTree=r,e.Mesh.prototype.raycast=t}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,13 @@
1
+ import { Camera, MeshDepthMaterial, Scene, WebGLRenderTarget, WebGLRenderer } from "three";
2
+ import { Pass } from "three-stdlib";
3
+ declare class DepthPass extends Pass {
4
+ private scene;
5
+ camera: Camera;
6
+ depthMaterial: MeshDepthMaterial;
7
+ depthRenderTarget: WebGLRenderTarget;
8
+ constructor(scene: Scene, camera: Camera, depthMaterial: MeshDepthMaterial, depthRenderTarget: WebGLRenderTarget);
9
+ dispose(): void;
10
+ setSize(width: any, height: any): void;
11
+ render(renderer: WebGLRenderer, writeBuffer: WebGLRenderTarget, readBuffer: WebGLRenderTarget, deltaTime: number, maskActive?: unknown): void;
12
+ }
13
+ export { DepthPass };
@@ -0,0 +1,5 @@
1
+ import{depthUniformName as e}from"../../shader-nodes/depth";import{Mesh as r}from"three";import{Pass as t}from"three-stdlib";class i extends t{constructor(e,r,t,i){super(),this.scene=e,this.camera=r,this.depthMaterial=t,this.depthRenderTarget=i,this.needsSwap=!0}dispose(){}setSize(e,r){}render(t,i,s,a,n){if(this.renderToScreen)t.setRenderTarget(null),t.render(this.scene,this.camera);else{const s=[];this.scene.traverse((t=>{var i,a,n,d;t instanceof r&&t.visible&&((null===(a=null===(i=t.material)||void 0===i?void 0:i.userData)||void 0===a?void 0:a.water)||(null===(n=t.material)||void 0===n?void 0:n.uniforms)&&null!=(null===(d=t.material)||void 0===d?void 0:d.uniforms[e]))&&(t.visible=!1,s.push(t))})),this.scene.overrideMaterial=this.depthMaterial,t.setRenderTarget(this.depthRenderTarget),t.render(this.scene,this.camera),this.scene.overrideMaterial=null,s.forEach((e=>e.visible=!0)),t.setRenderTarget(i),t.clear(),t.render(this.scene,this.camera)}}}export{i as DepthPass};
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */
@@ -0,0 +1,2 @@
1
+ import * as THREE from "three";
2
+ export declare function createLineSphere(radius: number): THREE.Object3D;
@@ -0,0 +1,5 @@
1
+ import*as e from"three";const t=new e.EllipseCurve(0,0,1,1,0,2*Math.PI,!1,0).getPoints(50),r=(new e.BufferGeometry).setFromPoints(t),o=new e.LineBasicMaterial({color:16777215,side:e.DoubleSide});function n(t){const n=new e.Line(r,o);return n.scale.multiplyScalar(t),n}export function createLineSphere(t){const r=n(t),o=n(t);o.rotateY(Math.PI/2),o.updateMatrixWorld();const a=n(t);return a.rotateX(Math.PI/2),a.updateMatrixWorld(),(new e.Group).add(r,o,a)}
2
+ /*
3
+ * Copyright (©) 2023. All rights reserved.
4
+ * See the LICENSE.md file for details.
5
+ */