emeraldengine 2.0.0

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 (73) hide show
  1. package/README.md +968 -0
  2. package/dist/types/imports/BitmapText.d.ts +79 -0
  3. package/dist/types/imports/Color.d.ts +17 -0
  4. package/dist/types/imports/Drawable.d.ts +157 -0
  5. package/dist/types/imports/Emerald.d.ts +73 -0
  6. package/dist/types/imports/FPSCounter.d.ts +19 -0
  7. package/dist/types/imports/GLUtils.d.ts +6 -0
  8. package/dist/types/imports/Instance.d.ts +87 -0
  9. package/dist/types/imports/InstancedTexture.d.ts +230 -0
  10. package/dist/types/imports/Physics.d.ts +139 -0
  11. package/dist/types/imports/Scene.d.ts +39 -0
  12. package/dist/types/imports/Shaders.d.ts +4 -0
  13. package/dist/types/imports/Shapes.d.ts +25 -0
  14. package/dist/types/imports/Storage.d.ts +46 -0
  15. package/dist/types/imports/Texture.d.ts +19 -0
  16. package/dist/types/imports/Time.d.ts +22 -0
  17. package/dist/types/imports/Transform.d.ts +41 -0
  18. package/dist/types/imports/components/BoxCollider.d.ts +41 -0
  19. package/dist/types/imports/components/BoxColliderDebug.d.ts +19 -0
  20. package/dist/types/imports/components/CircleCollider.d.ts +39 -0
  21. package/dist/types/imports/components/CircleColliderDebug.d.ts +19 -0
  22. package/dist/types/imports/components/Collider.d.ts +53 -0
  23. package/dist/types/imports/components/GameObject.d.ts +72 -0
  24. package/dist/types/imports/components/RigidBody.d.ts +104 -0
  25. package/dist/types/imports/lights/DirectionalLight.d.ts +26 -0
  26. package/dist/types/imports/lights/PointLight.d.ts +18 -0
  27. package/dist/types/imports/managers/AudioManager.d.ts +60 -0
  28. package/dist/types/imports/managers/CameraManager.d.ts +35 -0
  29. package/dist/types/imports/managers/EventManager.d.ts +187 -0
  30. package/dist/types/imports/managers/GLManager.d.ts +47 -0
  31. package/dist/types/imports/managers/IDManager.d.ts +21 -0
  32. package/dist/types/imports/managers/SceneManager.d.ts +22 -0
  33. package/dist/types/imports/particlesystem/Particle.d.ts +42 -0
  34. package/dist/types/imports/particlesystem/ParticleSettings.d.ts +49 -0
  35. package/dist/types/imports/particlesystem/Particles.d.ts +71 -0
  36. package/dist/types/index.d.ts +32 -0
  37. package/imports/BitmapText.js +245 -0
  38. package/imports/Color.js +18 -0
  39. package/imports/Drawable.js +550 -0
  40. package/imports/Emerald.js +459 -0
  41. package/imports/FPSCounter.js +43 -0
  42. package/imports/GLUtils.js +67 -0
  43. package/imports/Instance.js +187 -0
  44. package/imports/InstancedTexture.js +856 -0
  45. package/imports/Physics.js +242 -0
  46. package/imports/Scene.js +79 -0
  47. package/imports/Shaders.js +165 -0
  48. package/imports/Shapes.js +129 -0
  49. package/imports/Storage.js +63 -0
  50. package/imports/Texture.js +67 -0
  51. package/imports/Time.js +28 -0
  52. package/imports/Transform.js +59 -0
  53. package/imports/components/BoxCollider.js +67 -0
  54. package/imports/components/BoxColliderDebug.js +38 -0
  55. package/imports/components/CircleCollider.js +67 -0
  56. package/imports/components/CircleColliderDebug.js +36 -0
  57. package/imports/components/Collider.js +51 -0
  58. package/imports/components/GameObject.js +160 -0
  59. package/imports/components/RigidBody.js +169 -0
  60. package/imports/lights/DirectionalLight.js +68 -0
  61. package/imports/lights/PointLight.js +17 -0
  62. package/imports/managers/AudioManager.js +146 -0
  63. package/imports/managers/CameraManager.js +60 -0
  64. package/imports/managers/EventManager.js +479 -0
  65. package/imports/managers/GLManager.js +65 -0
  66. package/imports/managers/IDManager.js +32 -0
  67. package/imports/managers/SceneManager.js +27 -0
  68. package/imports/managers/ShaderManager.js +133 -0
  69. package/imports/particlesystem/Particle.js +75 -0
  70. package/imports/particlesystem/ParticleSettings.js +49 -0
  71. package/imports/particlesystem/Particles.js +226 -0
  72. package/index.js +67 -0
  73. package/package.json +38 -0
@@ -0,0 +1,79 @@
1
+ import Color from "./Color";
2
+ import GameObject from "./components/GameObject";
3
+ import InstancedTexture from "./InstancedTexture";
4
+ import { Vector3 } from "./Physics";
5
+ /**
6
+ * BitmapText class for rendering text using a bitmap font texture
7
+ * @param {string} text - The text to display
8
+ * @param {string} texturePath - Path to the bitmap font texture
9
+ * @param {string} letters - String containing all available characters in the font
10
+ * @param {number} letterSpacing - Spacing between letters
11
+ * @param {number} frameWidth - Width of each character frame
12
+ * @param {number} frameHeight - Height of each character frame
13
+ * @param {number} framesPerRow - Number of character frames per row in the texture
14
+ * @param {number} totalFrames - Total number of character frames
15
+ * @param {boolean} pixelArt - Whether to use pixel-perfect rendering
16
+ * @param {number} fontSize - Size of the rendered text
17
+ * @param {Color} color - Color tint for the text
18
+ * @param {Vector3} position - Position of the text
19
+ * @param {number} rotation - Rotation of the text
20
+ * @param {boolean} useLighting - Whether the text should react to lighting (default: false)
21
+ */
22
+ declare class BitmapText {
23
+ text: string;
24
+ texturePath: string;
25
+ fontSize: number;
26
+ color: Color;
27
+ position: Vector3;
28
+ rotation: number;
29
+ letters: string;
30
+ letterSpacing: number;
31
+ frameWidth: number;
32
+ frameHeight: number;
33
+ framesPerRow: number;
34
+ totalFrames: number;
35
+ pixelArt: boolean;
36
+ useLighting: boolean;
37
+ gameObject: GameObject;
38
+ letterDictionary: Record<string, number>;
39
+ texture: InstancedTexture;
40
+ constructor(text: string, texturePath: string, letters: string, letterSpacing: number, frameWidth: number, frameHeight: number, framesPerRow: number, totalFrames: number, pixelArt: boolean, fontSize: number, color: Color, position: Vector3, rotation: number, useLighting?: boolean);
41
+ /**
42
+ * @method setColor
43
+ * @description Updates the color of the bitmap text
44
+ * @param {Color} color - The color to set
45
+ */
46
+ setColor(color: Color): void;
47
+ /**
48
+ * @method setUseLighting
49
+ * @description Controls whether the text reacts to lighting
50
+ * @param {boolean} useLighting - Whether the text should react to lighting
51
+ */
52
+ setUseLighting(useLighting: boolean): void;
53
+ /**
54
+ * @method setText
55
+ * @description Updates the text of the bitmap text
56
+ * @param {string} text - The text to set
57
+ */
58
+ setText(text: string): void;
59
+ /**
60
+ * @method setPosition
61
+ * @description Updates the position of the bitmap text
62
+ * @param {Vector3} position - The position to set
63
+ */
64
+ setPosition(position: Vector3): void;
65
+ /**
66
+ * @method setFontSize
67
+ * @description Updates the font size of the bitmap text
68
+ * @param {number} fontSize - The font size to set
69
+ */
70
+ setFontSize(fontSize: number): void;
71
+ /**
72
+ * @method setLetterSpacing
73
+ * @description Updates the letter spacing of the bitmap text
74
+ * @param {number} letterSpacing - The letter spacing to set
75
+ */
76
+ setLetterSpacing(letterSpacing: number): void;
77
+ }
78
+ export default BitmapText;
79
+ //# sourceMappingURL=BitmapText.d.ts.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @class Color
3
+ * @description Represents a color
4
+ * @param {number} r - The red value
5
+ * @param {number} g - The green value
6
+ * @param {number} b - The blue value
7
+ * @param {number} a - The alpha value
8
+ */
9
+ declare class Color {
10
+ r: number;
11
+ g: number;
12
+ b: number;
13
+ a: number;
14
+ constructor(r: number, g: number, b: number, a?: number);
15
+ }
16
+ export default Color;
17
+ //# sourceMappingURL=Color.d.ts.map
@@ -0,0 +1,157 @@
1
+ import Color from "./Color";
2
+ import { mat4 } from "gl-matrix";
3
+ import GameObject from "./components/GameObject";
4
+ /**
5
+ * @class Drawable
6
+ * @description A class that represents a drawable object
7
+ * @param {WebGLRenderingContext} gl - The WebGL rendering context
8
+ * @param {Object} programInfo - The program information
9
+ * @param {WebGLBuffer} verticesBuffer - The vertices buffer
10
+ * @param {WebGLBuffer} texCoordBuffer - The texture coordinate buffer
11
+ * @param {Array} vertices - The vertices of the object
12
+ * @param {boolean} useTexture - Whether to use a texture
13
+ * @param {string} texturePath - The path to the texture
14
+ * @param {number} frameWidth - The width of the frame
15
+ * @param {number} frameHeight - The height of the frame
16
+ * @param {number} framesPerRow - The number of frames per row
17
+ * @param {number} totalFrames - The total number of frames
18
+ * @param {number} animationSpeed - The speed of the animation
19
+ * @param {boolean} autoplay - Whether to autoplay the animation
20
+ * @param {boolean} pixelart - Whether to use pixel art
21
+ * @param {boolean} useLighting - Whether to use lighting
22
+ */
23
+ declare class Drawable {
24
+ gl: WebGL2RenderingContext;
25
+ programInfo: any;
26
+ id: string;
27
+ verticesBuffer: WebGLBuffer;
28
+ texCoordBuffer: WebGLBuffer;
29
+ vertices: number[];
30
+ color: Color;
31
+ texturePath: string;
32
+ texture: WebGLTexture | null;
33
+ useTexture: boolean;
34
+ frameWidth: number;
35
+ frameHeight: number;
36
+ framesPerRow: number;
37
+ totalFrames: number;
38
+ currentFrame: number;
39
+ animationSpeed: number;
40
+ lastFrameTime: number;
41
+ textureWidth: number;
42
+ textureHeight: number;
43
+ isPlaying: boolean;
44
+ playOnce: boolean;
45
+ originalTexture: WebGLTexture | null;
46
+ mirrored: boolean;
47
+ animationType: string;
48
+ currentAnimationArray: number[];
49
+ currentAnimationIndex: number;
50
+ shouldRevertAfterPlayingOnce: boolean;
51
+ revertAnimation: number[];
52
+ parentObject: any;
53
+ isActive: boolean;
54
+ isWireframe: boolean;
55
+ callbackFunction: () => void;
56
+ pixelart: boolean;
57
+ useLighting: boolean;
58
+ constructor(gl: WebGL2RenderingContext, programInfo: any, verticesBuffer: WebGLBuffer, texCoordBuffer: WebGLBuffer, vertices: number[], useTexture: boolean, texturePath: string, frameWidth?: number, frameHeight?: number, framesPerRow?: number, totalFrames?: number, animationSpeed?: number, autoplay?: boolean, pixelart?: boolean, useLighting?: boolean);
59
+ /**
60
+ * @method setIsWireframe
61
+ * @description Sets the wireframe mode
62
+ * @param {boolean} bool - Whether to enable wireframe mode
63
+ */
64
+ setIsWireframe(bool: boolean): void;
65
+ /**
66
+ * @method setUseLighting
67
+ * @description Sets the lighting mode
68
+ * @param {boolean} useLighting - Whether to enable lighting reaction
69
+ */
70
+ setUseLighting(useLighting: boolean): void;
71
+ /**
72
+ * @method setIsActive
73
+ * @description Sets the active state
74
+ * @param {boolean} bool - Whether to enable the active state
75
+ */
76
+ setIsActive(bool: boolean): void;
77
+ /**
78
+ * @method setParent
79
+ * @description Sets the parent object
80
+ * @param {Object} parent - The parent object
81
+ */
82
+ setParent(parent: GameObject): void;
83
+ /**
84
+ * @method getParent
85
+ * @description Gets the parent object
86
+ * @returns {Object} - The parent object
87
+ */
88
+ getParent(): GameObject | null;
89
+ /**
90
+ * @method setColor
91
+ * @description Sets the color of the object
92
+ * @param {Color} color - The color to set
93
+ */
94
+ setColor(color: Color): void;
95
+ /**
96
+ * @method initTexture
97
+ * @description Initializes the texture
98
+ */
99
+ initTexture(): Promise<void>;
100
+ /**
101
+ * @method updateAnimation
102
+ * @description Updates the animation
103
+ * @param {number} currentTime - The current time
104
+ */
105
+ updateAnimation(currentTime: number): void;
106
+ /**
107
+ * @method getAnimation
108
+ * @description Gets the animation
109
+ * @returns {Array} - The animation
110
+ */
111
+ getAnimation(): number[] | string | null;
112
+ /**
113
+ * @method playAnimation
114
+ * @description Plays an animation
115
+ * @param {Array} animation - The animation to play
116
+ * @param {number} animationSpeed - The speed of the animation
117
+ */
118
+ playAnimation(animation: number[], animationSpeed?: number): void;
119
+ /**
120
+ * @method setFrame
121
+ * @description Sets the frame
122
+ * @param {number} frame - The frame to set
123
+ */
124
+ setFrame(frame: number): void;
125
+ /**
126
+ * @method playAnimationOnce
127
+ * @description Plays an animation once
128
+ * @param {Array} animation - The animation to play
129
+ * @param {Array} defaultAnimation - The default animation
130
+ * @param {number} animationSpeed - The speed of the animation
131
+ * @param {function} callbackFunction - The callback function
132
+ */
133
+ playAnimationOnce(animation: number[], defaultAnimation?: number[] | null, animationSpeed?: number, callbackFunction?: (() => void) | null): void;
134
+ /**
135
+ * @method stopAnimation
136
+ * @description Stops the animation
137
+ */
138
+ stopAnimation(): void;
139
+ /**
140
+ * @method draw
141
+ * @description Draws the object
142
+ * @param {mat4} globalViewMatrix - The global view matrix
143
+ * @param {WebGLUniformLocation} uniformLocation - The uniform location
144
+ * @param {number} currentTime - The current time
145
+ * @param {Object} objectTransform - The object transform
146
+ */
147
+ draw(globalViewMatrix: mat4, uniformLocation: WebGLUniformLocation, currentTime: number, objectTransform: any): void;
148
+ /**
149
+ * @method loadImage
150
+ * @description Loads an image
151
+ * @param {string} path - The path to the image
152
+ * @returns {Promise} - The promise
153
+ */
154
+ loadImage: (path: string) => Promise<unknown>;
155
+ }
156
+ export default Drawable;
157
+ //# sourceMappingURL=Drawable.d.ts.map
@@ -0,0 +1,73 @@
1
+ import Color from "./Color";
2
+ import { Vector3 } from "./Physics";
3
+ import PointLight from "./lights/PointLight";
4
+ import DirectionalLight from "./lights/DirectionalLight";
5
+ import Scene from "./Scene";
6
+ /**
7
+ * @class Emerald
8
+ * @description A class that represents the Emerald engine
9
+ * @param {HTMLCanvasElement} canvas - The canvas element
10
+ */
11
+ declare class Emerald {
12
+ shaderProgram: WebGLProgram;
13
+ gl: WebGL2RenderingContext;
14
+ programInfo: any;
15
+ camera: any;
16
+ ambientLight: Vector3;
17
+ pointLights: PointLight[];
18
+ directionalLights: DirectionalLight[];
19
+ debugLogged: boolean;
20
+ backgroundColor: {
21
+ r: number;
22
+ g: number;
23
+ b: number;
24
+ a: number;
25
+ };
26
+ constructor(canvas: HTMLCanvasElement);
27
+ /**
28
+ * @method setAmbientLight
29
+ * @description Sets the ambient light for the scene
30
+ * @param {Vector3} vector3 - The ambient light color as a Vector3 instance
31
+ */
32
+ setAmbientLight(vector3: Vector3): void;
33
+ /**
34
+ * @method resize
35
+ * @description Resizes the canvas
36
+ * @param {number} width - The width of the canvas
37
+ * @param {number} height - The height of the canvas
38
+ */
39
+ resize(width: number, height: number): void;
40
+ /**
41
+ * @method addPointLight
42
+ * @description Adds a point light to the scene
43
+ * @param {PointLight} pointLight - The point light to add
44
+ */
45
+ addPointLight(pointLight: PointLight): void;
46
+ /**
47
+ * @method addDirectionalLight
48
+ * @description Adds a directional light to the scene
49
+ * @param {DirectionalLight} directionalLight - The directional light to add
50
+ */
51
+ addDirectionalLight(directionalLight: DirectionalLight): void;
52
+ /**
53
+ * @method removeDirectionalLight
54
+ * @description Removes a directional light from the scene
55
+ * @param {DirectionalLight} directionalLight - The directional light to remove
56
+ */
57
+ removeDirectionalLight(directionalLight: DirectionalLight): void;
58
+ /**
59
+ * @method setBackgroundColor
60
+ * @description Sets the background color of the scene
61
+ * @param {Color} color - The background color
62
+ */
63
+ setBackgroundColor(color: Color): void;
64
+ /**
65
+ * @method drawScene
66
+ * @description Draws the scene
67
+ * @param {Scene} scene - The scene to draw
68
+ * @param {number} deltaTime - The delta time
69
+ */
70
+ drawScene(scene: Scene, deltaTime: number): void;
71
+ }
72
+ export default Emerald;
73
+ //# sourceMappingURL=Emerald.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @class FPSCounter
3
+ * @description Represents a FPS counter
4
+ */
5
+ declare class FPSCounter {
6
+ lastFrameTime: number;
7
+ frameCount: number;
8
+ fps: number;
9
+ fpsElement: HTMLDivElement;
10
+ accumulatedTime: number;
11
+ constructor();
12
+ /**
13
+ * @method update
14
+ * @description Updates the FPS counter
15
+ */
16
+ update(): void;
17
+ }
18
+ export default FPSCounter;
19
+ //# sourceMappingURL=FPSCounter.d.ts.map
@@ -0,0 +1,6 @@
1
+ declare function initShaderProgram(gl: WebGL2RenderingContext, vShader: string, fShader: string): WebGLProgram | null;
2
+ declare function loadShader(gl: WebGL2RenderingContext, type: number, source: string): WebGLShader | null;
3
+ declare const initVertexBuffer: (gl: WebGL2RenderingContext, vertices: number[]) => WebGLBuffer | null;
4
+ declare function initInstancedBuffer(gl: WebGL2RenderingContext, data: Float32Array, itemSize: number): WebGLBuffer | null;
5
+ export { initShaderProgram, loadShader, initVertexBuffer, initInstancedBuffer };
6
+ //# sourceMappingURL=GLUtils.d.ts.map
@@ -0,0 +1,87 @@
1
+ import InstancedTexture from "./InstancedTexture";
2
+ import { Vector2, Vector3 } from "./Physics";
3
+ import Transform from "./Transform";
4
+ /**
5
+ * @class Instance
6
+ * @description Represents an instance
7
+ * @param {string} name - The name of the instance
8
+ * @param {Vector3} position - The position of the instance
9
+ * @param {Vector2} scale - The scale of the instance
10
+ * @param {number} rotation - The rotation of the instance
11
+ * @param {number} frame - The frame of the instance
12
+ */
13
+ declare class Instance {
14
+ name: string;
15
+ transform: Transform;
16
+ id: string;
17
+ parent: InstancedTexture | null;
18
+ frame: number;
19
+ isAnimating: boolean;
20
+ animationFrames: number[];
21
+ currentAnimationIndex: number;
22
+ animationSpeed: number;
23
+ lastFrameTime: number;
24
+ playOnce: boolean;
25
+ originalFrame: number;
26
+ components: any[];
27
+ constructor(name: string, position?: Vector3, scale?: Vector2, rotation?: number, frame?: number);
28
+ /**
29
+ * @method setParent
30
+ * @description Sets the parent of the instance
31
+ * @param {Instance} parent - The parent of the instance
32
+ */
33
+ setParent(parent: InstancedTexture): void;
34
+ /**
35
+ * @method playAnimation
36
+ * @description Plays an animation with an array of frames
37
+ * @param {Array} frames - The frames to play
38
+ * @param {number} speed - The speed of the animation
39
+ */
40
+ playAnimation(frames: number[], speed?: number): void;
41
+ /**
42
+ * @method playAnimationOnce
43
+ * @description Plays an animation with an array of frames once then stops
44
+ * @param {Array} frames - The frames to play
45
+ * @param {number} speed - The speed of the animation
46
+ */
47
+ playAnimationOnce(frames: number[], speed?: number): void;
48
+ /**
49
+ * @method stopAnimation
50
+ * @description Stops the animation and optionally reverts to the original frame
51
+ * @param {boolean} revertToOriginal - Whether to revert to the original frame
52
+ */
53
+ stopAnimation(revertToOriginal?: boolean): void;
54
+ /**
55
+ * @method setFrame
56
+ * @description Sets a specific frame
57
+ * @param {number} frame - The frame to set
58
+ */
59
+ setFrame(frame: number): void;
60
+ /**
61
+ * @method updateAnimation
62
+ * @description Updates the animation
63
+ * @param {number} currentTime - The current time
64
+ */
65
+ updateAnimation(currentTime: number): boolean;
66
+ /**
67
+ * @method addComponent
68
+ * @description Adds a component to the instance
69
+ * @param {Component} componentInstance - The component to add
70
+ */
71
+ addComponent(componentInstance: any): void;
72
+ /**
73
+ * @method removeComponent
74
+ * @description Removes a component from the instance
75
+ * @param {Component} component - The component to remove
76
+ */
77
+ removeComponent(component: any): void;
78
+ /**
79
+ * @method getComponent
80
+ * @description Gets a component from the instance
81
+ * @param {Component} componentType - The type of the component to get
82
+ * @returns {Component} - The component
83
+ */
84
+ getComponent(componentType: any): any;
85
+ }
86
+ export default Instance;
87
+ //# sourceMappingURL=Instance.d.ts.map
@@ -0,0 +1,230 @@
1
+ import Instance from "./Instance";
2
+ import Drawable from "./Drawable";
3
+ import { Vector3 } from "./Physics";
4
+ /**
5
+ * @class InstancedTexture
6
+ * @description Represents an instanced texture component
7
+ * @param {string} texturePath - The path to the texture
8
+ * @param {number} instanceCount - The number of instances
9
+ * @param {number} frameWidth - The width of the frame
10
+ * @param {number} frameHeight - The height of the frame
11
+ * @param {number} framesPerRow - The number of frames per row
12
+ * @param {number} totalFrames - The total number of frames
13
+ * @param {number} animationSpeed - The speed of the animation
14
+ * @param {boolean} autoPlay - Whether to auto play the animation
15
+ * @param {boolean} pixelart - Whether to use pixel art
16
+ * @param {boolean} useLighting - Whether to use lighting
17
+ */
18
+ declare class InstancedTexture extends Drawable {
19
+ instanceCount: number;
20
+ instances: Instance[];
21
+ instanceMatrices: Float32Array;
22
+ instanceTexCoords: Float32Array;
23
+ instanceMatrixBuffer: WebGLBuffer;
24
+ instanceTexCoordBuffer: WebGLBuffer;
25
+ instanceClickListeners: Map<string, Set<Function>>;
26
+ instanceHoverListeners: Map<string, {
27
+ enter: Set<Function>;
28
+ leave: Set<Function>;
29
+ }>;
30
+ constructor(texturePath?: string, instanceCount?: number, frameWidth?: number, frameHeight?: number, framesPerRow?: number, totalFrames?: number, animationSpeed?: number, autoPlay?: boolean, pixelart?: boolean, useLighting?: boolean);
31
+ /**
32
+ * @method addInstance
33
+ * @description Adds an instance to the instanced texture
34
+ * @param {Instance} instance - The instance to add
35
+ */
36
+ addInstance(instance: Instance): void;
37
+ /**
38
+ * @method removeInstance
39
+ * @description Removes an instance from the instanced texture
40
+ * @param {string} instanceID - The ID of the instance to remove
41
+ */
42
+ removeInstance(instanceID: string): void;
43
+ /**
44
+ * @method clearInstances
45
+ * @description Clears all instances from the instanced texture
46
+ */
47
+ clearInstances(): void;
48
+ /**
49
+ * @method updateInstanceCount
50
+ * @description Updates the instance count of the instanced texture
51
+ * @param {number} newCount - The new instance count
52
+ */
53
+ updateInstanceCount(newCount: number): void;
54
+ /**
55
+ * @method updateInstanceMatrix
56
+ * @description Updates the transformation matrix for a specific instance
57
+ * @param {number} index - The index of the instance to update
58
+ */
59
+ updateInstanceMatrix(index: number): void;
60
+ /**
61
+ * @method updateAllInstanceMatrices
62
+ * @description Updates all instance matrices
63
+ */
64
+ updateAllInstanceMatrices(): void;
65
+ /**
66
+ * @method updateInstanceTexCoords
67
+ * @description Updates the texture coordinates for a specific instance
68
+ * @param {number} index - The index of the instance to update
69
+ */
70
+ updateInstanceTexCoords(index: number): void;
71
+ /**
72
+ * @method updateAllInstanceTexCoords
73
+ * @description Updates all instance texture coordinates
74
+ */
75
+ updateAllInstanceTexCoords(): void;
76
+ /**
77
+ * @method getInstanceWithId
78
+ * @description Gets an instance by its ID
79
+ * @param {string} id - The ID of the instance to get
80
+ * @returns {Instance} - The instance
81
+ */
82
+ getInstanceWithId(id: string): Instance | undefined;
83
+ /**
84
+ * @method update
85
+ * @description Updates the instanced texture
86
+ * @param {number} currentTime - The current time
87
+ */
88
+ update(currentTime: number): void;
89
+ /**
90
+ * @method animateInstance
91
+ * @description Starts animation on a specific instance
92
+ * @param {string} instanceId - The ID of the instance to animate
93
+ * @param {Array} frames - The frames to animate
94
+ * @param {number} speed - The speed of the animation
95
+ */
96
+ animateInstance(instanceId: string, frames: number[], speed?: number): void;
97
+ /**
98
+ * @method stopInstanceAnimation
99
+ * @description Stops animation on a specific instance
100
+ * @param {string} instanceId - The ID of the instance to stop animation
101
+ * @param {boolean} revertToOriginal - Whether to revert to the original frame
102
+ */
103
+ stopInstanceAnimation(instanceId: string, revertToOriginal?: boolean): void;
104
+ /**
105
+ * @method addClickEventToAllInstances
106
+ * @description Adds a click event to all instances
107
+ * @param {function} func - The function to call when the instance is clicked
108
+ */
109
+ addClickEventToAllInstances(func: Function): void;
110
+ /**
111
+ * @method addHoverEventToAllInstances
112
+ * @description Adds a hover event to all instances
113
+ * @param {function} enterFunc - The function to call when the instance is hovered
114
+ * @param {function} leaveFunc - The function to call when the instance is no longer hovered
115
+ */
116
+ addHoverEventToAllInstances(enterFunc: Function, leaveFunc: Function): void;
117
+ /**
118
+ * @method removeClickEventFromAllInstances
119
+ * @description Removes a click event from all instances
120
+ * @param {function} func - The function to remove
121
+ */
122
+ removeClickEventFromAllInstances(func: Function): void;
123
+ /**
124
+ * @method removeHoverEventFromAllInstances
125
+ * @description Removes a hover event from all instances
126
+ * @param {function} enterFunc - The function to remove
127
+ * @param {function} leaveFunc - The function to remove
128
+ */
129
+ removeHoverEventFromAllInstances(enterFunc: Function, leaveFunc: Function): void;
130
+ /**
131
+ * @method getFrameTexCoords
132
+ * @description Calculates the texture coordinates for a specific frame
133
+ * @param {number} frame - The frame to calculate the texture coordinates for
134
+ * @returns {Array} - The texture coordinates
135
+ */
136
+ getFrameTexCoords(frame: number): number[];
137
+ /**
138
+ * @method draw
139
+ * @description Draws the instanced texture
140
+ */
141
+ draw(): void;
142
+ /**
143
+ * @method setInstanceFrame
144
+ * @description Updates the frame of a specific instance
145
+ * @param {string} instanceId - The ID of the instance to update
146
+ * @param {number} frame - The frame to set
147
+ */
148
+ setInstanceFrame(instanceId: string, frame: number): void;
149
+ /**
150
+ * @method isPointInInstance
151
+ * @description Checks if a point is inside a specific instance
152
+ * @param {number} x - The x coordinate of the point
153
+ * @param {number} y - The y coordinate of the point
154
+ * @param {Instance} instance - The instance to check
155
+ * @returns {boolean} - Whether the point is inside the instance
156
+ */
157
+ isPointInInstance(x: number, y: number, instance: Instance): boolean;
158
+ /**
159
+ * @method getInstanceAtPosition
160
+ * @description Gets an instance at a specific position
161
+ * @param {Vector3} position - The position to check
162
+ * @param {number} tolerance - The tolerance for the position
163
+ * @returns {Instance} - The instance at the position
164
+ */
165
+ getInstanceAtPosition(position: Vector3, tolerance?: number): Instance | undefined;
166
+ /**
167
+ * @method getInstanceByFrame
168
+ * @description Gets an instance by its frame index
169
+ * @param {number} frameIndex - The frame index to get
170
+ * @returns {Instance} - The instance at the frame index
171
+ */
172
+ getInstanceByFrame(frameIndex: number): Instance | undefined;
173
+ /**
174
+ * @method getInstanceAtPoint
175
+ * @description Gets an instance at a specific point
176
+ * @param {number} x - The x coordinate of the point
177
+ * @param {number} y - The y coordinate of the point
178
+ * @returns {Instance} - The instance at the point
179
+ */
180
+ getInstanceAtPoint(x: number, y: number): Instance | undefined;
181
+ /**
182
+ * @method addInstanceClickEvent
183
+ * @description Adds a click event listener to a specific instance
184
+ * @param {string} instanceId - The ID of the instance to add the click event listener to
185
+ * @param {function} func - The function to call when the instance is clicked
186
+ */
187
+ addInstanceClickEvent(instanceId: string, func: Function): void;
188
+ /**
189
+ * @method removeInstanceClickEvent
190
+ * @description Removes a click event listener from a specific instance
191
+ * @param {string} instanceId - The ID of the instance to remove the click event listener from
192
+ * @param {function} func - The function to remove
193
+ */
194
+ removeInstanceClickEvent(instanceId: string, func: Function): void;
195
+ /**
196
+ * @method addInstanceHoverEvent
197
+ * @description Adds a hover event listener to a specific instance
198
+ * @param {string} instanceId - The ID of the instance to add the hover event listener to
199
+ * @param {function} enterFunc - The function to call when the instance is hovered
200
+ * @param {function} leaveFunc - The function to call when the instance is no longer hovered
201
+ */
202
+ addInstanceHoverEvent(instanceId: string, enterFunc: Function, leaveFunc: Function): void;
203
+ /**
204
+ * @method removeInstanceHoverEvent
205
+ * @description Removes a hover event listener from a specific instance
206
+ * @param {string} instanceId - The ID of the instance to remove the hover event listener from
207
+ * @param {function} enterFunc - The function to remove
208
+ * @param {function} leaveFunc - The function to remove
209
+ */
210
+ removeInstanceHoverEvent(instanceId: string, enterFunc: Function, leaveFunc: Function): void;
211
+ /**
212
+ * @method handleInstanceClick
213
+ * @description Handles a click event for a specific instance
214
+ * @param {Event} event - The event to handle
215
+ * @param {number} x - The x coordinate of the click
216
+ * @param {number} y - The y coordinate of the click
217
+ */
218
+ handleInstanceClick(event: Event, x: number, y: number): boolean;
219
+ /**
220
+ * @method handleInstanceHover
221
+ * @description Handles a hover event for a specific instance
222
+ * @param {Event} event - The event to handle
223
+ * @param {number} x - The x coordinate of the hover
224
+ * @param {number} y - The y coordinate of the hover
225
+ * @param {Instance} lastHoveredInstance - The last hovered instance
226
+ */
227
+ handleInstanceHover(event: Event, x: number, y: number, lastHoveredInstance: Instance | undefined): Instance | undefined;
228
+ }
229
+ export default InstancedTexture;
230
+ //# sourceMappingURL=InstancedTexture.d.ts.map