From b60ae2fd308a4fa4d31b5dc9af3c3fa8ab53d321 Mon Sep 17 00:00:00 2001 From: Agustin Mendez Date: Mon, 11 Feb 2019 13:08:41 -0300 Subject: [PATCH] refactor: pointer events and some bug fixes (#539) Fixes #538 Closes #512 Fixes #472 Closes [decentraland/builder#146](https://github.com/decentraland/builder/issues/146) Closes [decentraland/builder#144](https://github.com/decentraland/builder/issues/144) --- package-lock.json | 6 +- package.json | 2 +- packages/dcl/WebGLParcelScene.ts | 4 +- packages/dcl/entities/utils/AvatarEntity.ts | 13 +- .../entities/utils/checkParcelSceneLimits.ts | 20 +- packages/dcl/widgets/ui.ts | 2 - .../src/decentraland/Input.ts | 134 +- .../src/decentraland/Types.ts | 35 +- .../src/decentraland/math/Quaternion.ts | 37 +- packages/decentraland-ecs/src/ecs/Entity.ts | 51 +- .../types/dcl/decentraland-ecs.api.json | 232 +- .../decentraland-ecs/types/dcl/index.d.ts | 10537 ++++++++-------- .../decentraland-loader/src/parcelScene.ts | 7 +- packages/engine/components/Billboard.ts | 4 - .../DisposableComponent.ts | 1 - .../disposableComponents/GLTFShape.ts | 2 +- .../disposableComponents/OBJShape.ts | 2 +- .../disposableComponents/ui/UIImage.ts | 12 +- .../disposableComponents/ui/UIInputText.ts | 11 - .../disposableComponents/ui/UISlider.ts | 9 - .../components/ephemeralComponents/Gizmos.ts | 24 +- .../ephemeralComponents/HighlightBox.ts | 7 +- .../ephemeralComponents/TextShape.ts | 3 +- .../ephemeralComponents/Transform.ts | 5 +- .../components/helpers/schemaValidator.ts | 8 +- packages/engine/entities/BaseEntity.ts | 67 +- packages/engine/entities/InputTextEntity.ts | 90 - .../engine/entities/SharedSceneContext.ts | 147 +- .../engine/entities/utils/processModels.ts | 3 +- .../engine/renderer/ambientConfigurations.ts | 4 + packages/engine/renderer/camera.ts | 21 - packages/engine/renderer/index.ts | 4 +- packages/engine/renderer/input.ts | 159 +- packages/entryPoints/editor.ts | 1 + packages/scene-system/scene.system.ts | 58 +- packages/shared/comms/index.ts | 7 +- packages/shared/types.ts | 24 - packages/shared/world/SceneWorker.ts | 41 +- packages/shared/world/parcelSceneManager.ts | 3 +- packages/shared/world/positionThings.ts | 17 +- packages/unity-interface/dcl.ts | 17 +- public/ecs-parcels/-200.2-sound-test/game.ts | 4 +- .../ecs-parcels/-200.3-animation-clip/game.ts | 2 +- .../-200.4-ethereum-controller/game.ts | 2 +- public/local-ipfs/mappings | 421 + .../test-parcels/-1.49.interactions/game.ts | 4 +- .../-100.100.gamekit-cube/game.ts | 5 +- .../-100.104.material-component/game.ts | 50 +- .../test-parcels/-100.109.input-api/game.ts | 21 +- .../-100.111.SkeletalAnimation/game.ts | 20 +- .../-101.100-interaction-count/game.ts | 85 + .../-101.100-interaction-count/scene.json | 30 + .../-101.100-interaction-count/tsconfig.json | 7 + public/test-parcels/-102.102.gizmos/game.ts | 4 +- .../test-parcels/-200.236-uuid-events/game.ts | 4 +- scripts/test.ts | 2 + static/index.html | 3 +- test/index.ts | 1 + test/results/aframePrimitivesResult.0.png | 4 +- test/results/aframePrimitivesResult.1.png | 4 +- test/results/aframePrimitivesResult.2.png | 4 +- test/results/aframePrimitivesResult.3.png | 4 +- test/results/atlas.png | 4 +- test/results/avatar-profile-ui.png | 4 +- test/results/crocs.png | 4 +- test/results/gamekit-gltf.png | 4 +- test/results/gamekit-primitives.png | 4 +- test/results/inclusiveLimits.png | 4 +- test/results/lookAt.png | 4 +- test/results/material-billboard.png | 4 +- test/results/parcel-shape.png | 4 +- test/results/referenceSystem.3.png | 4 +- test/results/skyAndLights.0.png | 4 +- test/results/skyAndLights.1.png | 4 +- test/results/skyAndLights.3.png | 4 +- test/results/text.png | 4 +- test/results/transparent.2.png | 4 +- test/results/transparent.png | 4 +- test/testHelpers.ts | 22 +- test/unit/ecs.test.tsx | 873 +- test/visualValidation/avatar.test.tsx | 3 +- test/visualValidation/ccPaymentUI.test.tsx | 1 - 82 files changed, 7149 insertions(+), 6326 deletions(-) delete mode 100644 packages/engine/entities/InputTextEntity.ts create mode 100644 public/test-parcels/-101.100-interaction-count/game.ts create mode 100644 public/test-parcels/-101.100-interaction-count/scene.json create mode 100644 public/test-parcels/-101.100-interaction-count/tsconfig.json diff --git a/package-lock.json b/package-lock.json index 3d80d2e19..fcd4cc6d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3071,9 +3071,9 @@ "dev": true }, "fp-future": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fp-future/-/fp-future-1.0.0.tgz", - "integrity": "sha512-D+GXA9HU7L8fwZJT/76l8UGNHx1Qvq73IoVX3mWvGcDVlsGboh/ZU5c3iOhbqA0ahMynNriJouni8cBeJo33Pg==" + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fp-future/-/fp-future-1.0.1.tgz", + "integrity": "sha512-2McmZH/KsZqlqHju9+Ox0FC7q7Knve4t6ZeKubbhAz1xpnD7hkCrP8TP5g5QbbD5bA5jBANbXf/ew4x1FjSUrw==" }, "fragment-cache": { "version": "0.2.1", diff --git a/package.json b/package.json index e65f057a0..cf80cfc76 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "ephemeralkey": "^2.0.1", "eth-connect": "^4.0.0", "ethereum-blockies": "^0.1.1", - "fp-future": "^1.0.0", + "fp-future": "^1.0.1", "google-protobuf": "^3.6.1", "hammerjs": "^2.0.8", "keccakjs": "^0.2.1", diff --git a/packages/dcl/WebGLParcelScene.ts b/packages/dcl/WebGLParcelScene.ts index cfed84ae9..dbf532c89 100644 --- a/packages/dcl/WebGLParcelScene.ts +++ b/packages/dcl/WebGLParcelScene.ts @@ -17,10 +17,9 @@ import { scene } from 'engine/renderer' export class WebGLParcelScene extends WebGLScene { public encodedPositions: string + public setOfEntitiesOutsideBoundaries = new Set() - private setOfEntitiesOutsideBoundaries = new Set() private parcelSet = new Set() - private shouldValidateBoundaries = false constructor(public data: EnvironmentData) { @@ -143,6 +142,7 @@ export class WebGLParcelScene extends WebGLScene { */ checkBoundaries() { const newSet = new Set() + this.context.entities.forEach(entity => checkParcelSceneBoundaries(this.parcelSet, newSet, entity)) // remove the highlight from the entities that were outside but they are no longer outside this.setOfEntitiesOutsideBoundaries.forEach($ => { diff --git a/packages/dcl/entities/utils/AvatarEntity.ts b/packages/dcl/entities/utils/AvatarEntity.ts index ead6aaace..b616edd28 100644 --- a/packages/dcl/entities/utils/AvatarEntity.ts +++ b/packages/dcl/entities/utils/AvatarEntity.ts @@ -8,19 +8,18 @@ import { profileObservable, ProfileEvent } from 'shared/comms/profile' import { SharedSceneContext } from 'engine/entities/SharedSceneContext' import { uuid } from 'atomicHelpers/math' import { setEntityText } from 'engine/components/ephemeralComponents/TextShape' -import { Vector3Component, QuaternionComponent } from 'shared/types' -import { Color3 } from 'decentraland-ecs/src' +import { Color3, ReadOnlyVector3, ReadOnlyQuaternion } from 'decentraland-ecs/src' export type AvatarAttributes = { displayName: string publicKey: string avatarType?: string - leftHandPosition: Vector3Component - rightHandPosition: Vector3Component + leftHandPosition: ReadOnlyVector3 + rightHandPosition: ReadOnlyVector3 - headRotation: Vector3Component - leftHandRotation: QuaternionComponent - rightHandRotation: QuaternionComponent + headRotation: ReadOnlyVector3 + leftHandRotation: ReadOnlyQuaternion + rightHandRotation: ReadOnlyQuaternion muted: boolean diff --git a/packages/dcl/entities/utils/checkParcelSceneLimits.ts b/packages/dcl/entities/utils/checkParcelSceneLimits.ts index 390db406d..97ee50bd1 100644 --- a/packages/dcl/entities/utils/checkParcelSceneLimits.ts +++ b/packages/dcl/entities/utils/checkParcelSceneLimits.ts @@ -49,18 +49,6 @@ export function measureObject3D(obj: BABYLON.AbstractMesh | BABYLON.Mesh | BABYL return { entities, triangles, bodies, textures, materials, geometries } } -function totalBoundingInfo(meshes: BABYLON.AbstractMesh[]) { - let boundingInfo = meshes[0].getBoundingInfo() - let min = boundingInfo.boundingBox.minimumWorld.add(meshes[0].position) - let max = boundingInfo.boundingBox.maximumWorld.add(meshes[0].position) - for (let i = 1; i < meshes.length; i++) { - boundingInfo = meshes[i].getBoundingInfo() - min = BABYLON.Vector3.Minimize(min, boundingInfo.boundingBox.minimumWorld.add(meshes[i].position)) - max = BABYLON.Vector3.Maximize(max, boundingInfo.boundingBox.maximumWorld.add(meshes[i].position)) - } - return new BABYLON.BoundingInfo(min, max) -} - /** * Returns the objects that are outside the parcelScene limits. * Receives the encoded parcelScene parcels and the entity to traverse @@ -88,13 +76,7 @@ export function checkParcelSceneBoundaries( return 'BREAK' } - const meshes = mesh.getChildMeshes(false) - - if (meshes.length === 0) { - return 'CONTINUE' - } - - const bbox = totalBoundingInfo(meshes) + const bbox = entity.getMeshesBoundingBox() if (bbox.maximum.y > maxHeight || bbox.minimum.y < minHeight) { objectsOutside.add(entity) diff --git a/packages/dcl/widgets/ui.ts b/packages/dcl/widgets/ui.ts index a91cc57db..d80a248a7 100644 --- a/packages/dcl/widgets/ui.ts +++ b/packages/dcl/widgets/ui.ts @@ -33,7 +33,6 @@ export class WebGLUIScene extends WebGLScene { export async function initHudSystem(): Promise { const context = new SharedSceneContext('/', 'ui-context-hud', false) - context.isInternal = true const scene = new WebGLUIScene('hud', hudWorkerUrl, context) const system = await scene.worker.system @@ -46,7 +45,6 @@ export async function initHudSystem(): Promise { export async function initChatSystem(): Promise { const context = new SharedSceneContext('/', 'ui-context-chat', false) - context.isInternal = true const scene = new WebGLUIScene('chat', chatWorkerUrl, context) const system = await scene.worker.system diff --git a/packages/decentraland-ecs/src/decentraland/Input.ts b/packages/decentraland-ecs/src/decentraland/Input.ts index 58d3ee118..e37f91d80 100644 --- a/packages/decentraland-ecs/src/decentraland/Input.ts +++ b/packages/decentraland-ecs/src/decentraland/Input.ts @@ -1,5 +1,9 @@ -import { DecentralandInterface } from './Types' +// tslint:disable:ter-indent +// tslint:disable:ter-indent + +import { DecentralandInterface, PointerEvent } from './Types' import { Vector3 } from './math' +import { Component, DisposableComponent } from '../ecs/Component' declare let dcl: DecentralandInterface | void @@ -20,28 +24,42 @@ export type InputState = Record< } > -export type EnginePointerEvent = { - /** Origin of the ray */ - from: { x: number; y: number; z: number } - /** Direction vector of the ray (normalized) */ - direction: { x: number; y: number; z: number } - /** Length of the ray */ - length: number - /** ID of the pointer that triggered the event */ - pointerId: number +export type LocalPointerEvent = PointerEvent & { + origin: Vector3 + direction: Vector3 + pointer: Pointer + hit?: PointerEvent['hit'] & { + hitPoint: Vector3 + normal: Vector3 + worldNormal: Vector3 + } } -export type PointerEvent = { - /** Origin of the ray */ - from: Vector3 - /** Direction vector of the ray (normalized) */ - direction: Vector3 - /** Length of the ray */ - length: number - /** ID of the pointer that triggered the event */ - pointerId: Pointer +/** + * @public + */ +export class PointerEventComponent { + constructor(public readonly callback: (event: LocalPointerEvent) => void) { + if (!callback || !('apply' in callback) || !('call' in callback)) { + throw new Error('Callback is not a function') + } + // tslint:disable-next-line:no-use-before-declare + Input.ensureInstance() + } } +/** + * @public + */ +@Component('pointerDown') +export class OnPointerDown extends PointerEventComponent {} + +/** + * @public + */ +@Component('pointerUp') +export class OnPointerUp extends PointerEventComponent {} + /** * @public */ @@ -49,9 +67,7 @@ export class Input { private static _instance: Input static get instance(): Input { - if (!Input._instance) { - Input._instance = new Input() - } + Input.ensureInstance() return Input._instance } @@ -59,7 +75,7 @@ export class Input { return this.internalState } - private subscriptions: Record void>> = { + private subscriptions: Record void>> = { BUTTON_A_DOWN: [], BUTTON_A_UP: [] } @@ -73,21 +89,27 @@ export class Input { } } - constructor() { + private constructor() { if (typeof dcl !== 'undefined') { dcl.subscribe('pointerUp') dcl.subscribe('pointerDown') dcl.onEvent(event => { if (event.type === 'pointerUp') { - this.handlePointerUp(event.data as EnginePointerEvent) + this.handlePointerUp(event.data as PointerEvent) } else if (event.type === 'pointerDown') { - this.handlePointerDown(event.data as EnginePointerEvent) + this.handlePointerDown(event.data as PointerEvent) } }) } } + static ensureInstance(): any { + if (!Input._instance) { + Input._instance = new Input() + } + } + /** * Subscribes to an input event and triggers the provided callback. * @@ -95,7 +117,7 @@ export class Input { * @param eventName - The name of the event (see InputEventKind). * @param fn - A callback function to be called when the event is triggered. */ - public subscribe(eventName: InputEventKind, fn: (e: PointerEvent) => void) { + public subscribe(eventName: InputEventKind, fn: (e: LocalPointerEvent) => void) { this.subscriptions[eventName].push(fn) return () => this.unsubscribe(eventName, fn) } @@ -105,7 +127,7 @@ export class Input { * @param eventName - The name of the event (see InputEventKind). * @param fn - The callback function used when subscribing to the event. */ - public unsubscribe(eventName: InputEventKind, fn: (e: PointerEvent) => void) { + public unsubscribe(eventName: InputEventKind, fn: (e: LocalPointerEvent) => void) { const index = this.subscriptions[eventName].indexOf(fn) if (index > -1) { this.subscriptions[eventName].splice(index, 1) @@ -117,13 +139,21 @@ export class Input { return Pointer.SECONDARY } - private handlePointerUp(data: EnginePointerEvent) { + private handlePointerUp(data: PointerEvent) { const pointer = this.getPointerById(data.pointerId) - const newData = { - length: data.length, - from: new Vector3(data.from.x, data.from.y, data.from.z), - direction: new Vector3(data.direction.x, data.direction.y, data.direction.z), - pointerId: pointer + const newData: LocalPointerEvent = { + ...data, + pointer, + direction: new Vector3().copyFrom(data.direction), + origin: new Vector3().copyFrom(data.origin), + hit: data.hit + ? { + ...data.hit, + hitPoint: new Vector3().copyFrom(data.hit.hitPoint), + normal: new Vector3().copyFrom(data.hit.normal), + worldNormal: new Vector3().copyFrom(data.hit.worldNormal) + } + : undefined } this.internalState[Pointer.PRIMARY].BUTTON_A_DOWN = false @@ -131,15 +161,31 @@ export class Input { for (let i = 0; i < this.subscriptions['BUTTON_A_UP'].length; i++) { this.subscriptions['BUTTON_A_UP'][i](newData) } + + if (newData.hit && newData.hit.entityId && DisposableComponent.engine) { + const entity = DisposableComponent.engine.entities[newData.hit.entityId] + const handler = entity && entity.getOrNull(OnPointerUp) + if (handler) { + handler.callback(newData) + } + } } - private handlePointerDown(data: EnginePointerEvent) { + private handlePointerDown(data: PointerEvent) { const pointer = this.getPointerById(data.pointerId) - const newData = { - length: data.length, - from: new Vector3(data.from.x, data.from.y, data.from.z), - direction: new Vector3(data.direction.x, data.direction.y, data.direction.z), - pointerId: pointer + const newData: LocalPointerEvent = { + ...data, + pointer, + direction: new Vector3().copyFrom(data.direction), + origin: new Vector3().copyFrom(data.origin), + hit: data.hit + ? { + ...data.hit, + hitPoint: new Vector3().copyFrom(data.hit.hitPoint), + normal: new Vector3().copyFrom(data.hit.normal), + worldNormal: new Vector3().copyFrom(data.hit.worldNormal) + } + : undefined } this.internalState[Pointer.PRIMARY].BUTTON_A_DOWN = true @@ -147,5 +193,13 @@ export class Input { for (let i = 0; i < this.subscriptions['BUTTON_A_DOWN'].length; i++) { this.subscriptions['BUTTON_A_DOWN'][i](newData) } + + if (newData.hit && newData.hit.entityId && DisposableComponent.engine) { + const entity = DisposableComponent.engine.entities[newData.hit.entityId] + const handler = entity && entity.getOrNull(OnPointerDown) + if (handler) { + handler.callback(newData) + } + } } } diff --git a/packages/decentraland-ecs/src/decentraland/Types.ts b/packages/decentraland-ecs/src/decentraland/Types.ts index 290bed8bc..e07bc7ef3 100644 --- a/packages/decentraland-ecs/src/decentraland/Types.ts +++ b/packages/decentraland-ecs/src/decentraland/Types.ts @@ -82,14 +82,27 @@ export type DecentralandInterface = { } export type PointerEvent = { - /** Origin of the ray */ - from: ReadOnlyVector3 + /** Origin of the ray, relative to the scene */ + origin: ReadOnlyVector3 /** Direction vector of the ray (normalized) */ direction: ReadOnlyVector3 - /** Length of the ray */ - length: number /** ID of the pointer that triggered the event */ pointerId: number + /** Does this pointer event hit any object? */ + hit?: { + /** Length of the ray */ + length: number + /** If the ray hits a mesh the intersection point will be this */ + hitPoint: ReadOnlyVector3 + /** If the mesh has a name, it will be assigned to meshName */ + meshName: string + /** Normal of the hit */ + normal: ReadOnlyVector3 + /** Normal of the hit, in world space */ + worldNormal: ReadOnlyVector3 + /** Hit entity ID if any */ + entityId: string + } } export interface IEvents { @@ -119,18 +132,6 @@ export interface IEvents { quaternion: ReadOnlyQuaternion } - /** - * `click` is triggered when a user points and the ray (from mouse or controller) hits the entity. - * Notice: Only entities with ID will be listening for click events. - */ - click: { - /** ID of the entitiy of the event */ - entityId: string - - /** ID of the pointer that triggered the event */ - pointerId: number - } - /** * `pointerUp` is triggered when the user releases an input pointer. * It could be a VR controller, a touch screen or the mouse. @@ -192,9 +193,9 @@ export interface IEvents { pointerId: number } + /** The onClick event is only used for UI elements */ onClick: { entityId: string - pointerId: number } /** diff --git a/packages/decentraland-ecs/src/decentraland/math/Quaternion.ts b/packages/decentraland-ecs/src/decentraland/math/Quaternion.ts index db864595e..1c6a4606d 100644 --- a/packages/decentraland-ecs/src/decentraland/math/Quaternion.ts +++ b/packages/decentraland-ecs/src/decentraland/math/Quaternion.ts @@ -106,7 +106,7 @@ export class Quaternion { * @param right - defines the right operand * @returns the dot product */ - public static Dot(left: Quaternion, right: Quaternion): number { + public static Dot(left: ReadOnlyQuaternion, right: ReadOnlyQuaternion): number { return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w } @@ -116,7 +116,7 @@ export class Quaternion { * @param quat1 - defines the second quaternion to check * @returns true if the two quaternions are close to each other */ - public static AreClose(quat0: Quaternion, quat1: Quaternion): boolean { + public static AreClose(quat0: ReadOnlyQuaternion, quat1: ReadOnlyQuaternion): boolean { let dot = Quaternion.Dot(quat0, quat1) return dot >= 0 @@ -144,7 +144,7 @@ export class Quaternion { * @param quaternion - defines the quaternion to check * @returns true if the quaternion is identity */ - public static IsIdentity(quaternion: Quaternion): boolean { + public static IsIdentity(quaternion: ReadOnlyQuaternion): boolean { return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1 } @@ -298,7 +298,7 @@ export class Quaternion { * @param amount - defines the gradient to use * @returns the new interpolated quaternion */ - public static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion { + public static Slerp(left: ReadOnlyQuaternion, right: ReadOnlyQuaternion, amount: number): Quaternion { let result = Quaternion.Identity Quaternion.SlerpToRef(left, right, amount, result) @@ -313,7 +313,12 @@ export class Quaternion { * @param amount - defines the gradient to use * @param result - defines the target quaternion */ - public static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void { + public static SlerpToRef( + left: ReadOnlyQuaternion, + right: ReadOnlyQuaternion, + amount: number, + result: Quaternion + ): void { let num2 let num3 let num4 = left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w @@ -350,10 +355,10 @@ export class Quaternion { * @returns the new interpolated quaternion */ public static Hermite( - value1: Quaternion, - tangent1: Quaternion, - value2: Quaternion, - tangent2: Quaternion, + value1: ReadOnlyQuaternion, + tangent1: ReadOnlyQuaternion, + value2: ReadOnlyQuaternion, + tangent2: ReadOnlyQuaternion, amount: number ): Quaternion { let squared = amount * amount @@ -383,7 +388,7 @@ export class Quaternion { * @param quat1 - defines the first quaternion * @param quat2 - defines the second quaternion */ - public static Angle(quat1: Quaternion, quat2: Quaternion): number { + public static Angle(quat1: ReadOnlyQuaternion, quat2: ReadOnlyQuaternion): number { const dot = Quaternion.Dot(quat1, quat2) return Math.acos(Math.min(Math.abs(dot), 1)) * 2 * RAD2DEG } @@ -465,7 +470,7 @@ export class Quaternion { * @param to - defines the second quaternion * @param maxDegreesDelta - the interval step */ - public static RotateTowards(from: Quaternion, to: Quaternion, maxDegreesDelta: number): Quaternion { + public static RotateTowards(from: ReadOnlyQuaternion, to: Quaternion, maxDegreesDelta: number): Quaternion { const num: number = Quaternion.Angle(from, to) if (num === 0) { return to @@ -611,7 +616,7 @@ export class Quaternion { * @param otherQuaternion - defines the second operand * @returns true if the current quaternion and the given one coordinates are strictly equals */ - public equals(otherQuaternion: Quaternion): boolean { + public equals(otherQuaternion: ReadOnlyQuaternion): boolean { return ( otherQuaternion && this.x === otherQuaternion.x && @@ -634,7 +639,7 @@ export class Quaternion { * @param other - defines the other quaternion * @returns the updated current quaternion */ - public copyFrom(other: Quaternion): Quaternion { + public copyFrom(other: ReadOnlyQuaternion): Quaternion { this.x = other.x this.y = other.y this.z = other.z @@ -767,7 +772,7 @@ export class Quaternion { * @param q1 - defines the second operand * @returns a new quaternion set as the multiplication result of the current one with the given one "q1" */ - public multiply(q1: Quaternion): Quaternion { + public multiply(q1: ReadOnlyQuaternion): Quaternion { let result = new Quaternion(0, 0, 0, 1.0) this.multiplyToRef(q1, result) return result @@ -779,7 +784,7 @@ export class Quaternion { * @param result - defines the target quaternion * @returns the current quaternion */ - public multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion { + public multiplyToRef(q1: ReadOnlyQuaternion, result: Quaternion): Quaternion { let x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x let y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y let z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z @@ -793,7 +798,7 @@ export class Quaternion { * @param q1 - defines the second operand * @returns the currentupdated quaternion */ - public multiplyInPlace(q1: Quaternion): Quaternion { + public multiplyInPlace(q1: ReadOnlyQuaternion): Quaternion { this.multiplyToRef(q1, this) return this } diff --git a/packages/decentraland-ecs/src/ecs/Entity.ts b/packages/decentraland-ecs/src/ecs/Entity.ts index d5d84e231..0c1e4a624 100644 --- a/packages/decentraland-ecs/src/ecs/Entity.ts +++ b/packages/decentraland-ecs/src/ecs/Entity.ts @@ -49,7 +49,7 @@ export class Entity { if (this.components[componentName] === component) { return } - this.remove(this.components[componentName]) + this.remove(this.components[componentName], false) } this.add(component) @@ -203,23 +203,50 @@ export class Entity { /** * Removes a component instance from the entity. * @param component - component instance to remove + * @param triggerRemovedEvent - should this action trigger an event? */ - remove(component: string): void - remove(component: T): void - remove(component: object | string): void { - const componentName = typeof component === 'string' ? component : getComponentName(component) - let componentRemoved = null + remove(component: string, triggerRemovedEvent?: boolean): void + remove(component: T, triggerRemovedEvent?: boolean): void + remove(component: ComponentConstructor, triggerRemovedEvent?: boolean): void + remove(component: object | string | Function, triggerRemovedEvent = true): void { + const typeOfComponent = typeof component - if (this.components[componentName]) { - componentRemoved = this.components[componentName] - delete this.components[componentName] - } else { + if (typeOfComponent !== 'string' && typeOfComponent !== 'function' && typeOfComponent !== 'object') { + throw new Error('Entity#remove(component): component is not a class, class or name') + } + + const componentName = typeOfComponent === 'string' ? (component as string) : getComponentName(component as any) + + const storedComponent = this.components[componentName] + + if (!storedComponent) { log(`Entity Warning: Trying to remove inexisting component "${componentName}" from entity "${this.identifier}"`) + return + } + + if (typeOfComponent === 'function') { + if (storedComponent instanceof (component as ComponentConstructor)) { + delete this.components[componentName] + + if (triggerRemovedEvent && this.eventManager && storedComponent) { + this.eventManager.fireEvent(new ComponentRemoved(this, componentName, storedComponent)) + } + return + } else { + log( + `Entity Warning: Trying to remove wrong (by constructor) component "${componentName}" from entity "${ + this.identifier + }"` + ) + return + } } - if (this.eventManager && componentRemoved) { - this.eventManager.fireEvent(new ComponentRemoved(this, componentName, componentRemoved)) + delete this.components[componentName] + if (triggerRemovedEvent && this.eventManager && storedComponent) { + this.eventManager.fireEvent(new ComponentRemoved(this, componentName, storedComponent)) } + return } /** diff --git a/packages/decentraland-ecs/types/dcl/decentraland-ecs.api.json b/packages/decentraland-ecs/types/dcl/decentraland-ecs.api.json index 323457856..f7c6b6bae 100644 --- a/packages/decentraland-ecs/types/dcl/decentraland-ecs.api.json +++ b/packages/decentraland-ecs/types/dcl/decentraland-ecs.api.json @@ -7643,7 +7643,7 @@ }, "has": { "kind": "method", - "signature": "has(component: ComponentConstructor): boolean;", + "signature": "has(component: string): boolean;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -7657,12 +7657,12 @@ "description": [ { "kind": "text", - "text": "component class or name" + "text": "component class, instance or name" } ], "isOptional": false, "isSpread": false, - "type": "ComponentConstructor" + "type": "string" } }, "deprecatedMessage": [], @@ -7720,7 +7720,7 @@ }, "remove": { "kind": "method", - "signature": "remove(component: string): void;", + "signature": "remove(component: string, triggerRemovedEvent?: boolean): void;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -7740,6 +7740,18 @@ "isOptional": false, "isSpread": false, "type": "string" + }, + "triggerRemovedEvent": { + "name": "triggerRemovedEvent", + "description": [ + { + "kind": "text", + "text": "should this action trigger an event?" + } + ], + "isOptional": true, + "isSpread": false, + "type": "boolean" } }, "deprecatedMessage": [], @@ -8652,37 +8664,24 @@ "isBeta": false, "isSealed": false, "members": { - "__constructor": { - "kind": "constructor", - "signature": "constructor();", + "ensureInstance": { + "kind": "method", + "signature": "static ensureInstance(): any;", + "accessModifier": "", + "isOptional": false, + "isStatic": true, + "returnValue": { + "type": "any", + "description": [] + }, "parameters": {}, "deprecatedMessage": [], - "summary": [ - { - "kind": "text", - "text": "Constructs a new instance of the " - }, - { - "kind": "api-link", - "elements": [ - { - "kind": "text", - "text": "Input" - } - ], - "target": { - "scopeName": "", - "packageName": "decentraland-ecs", - "exportName": "Input", - "memberName": "" - } - }, - { - "kind": "text", - "text": " class" - } - ], - "remarks": [] + "summary": [], + "remarks": [], + "isBeta": false, + "isSealed": false, + "isVirtual": false, + "isOverride": false }, "instance": { "kind": "property", @@ -8718,7 +8717,7 @@ }, "subscribe": { "kind": "method", - "signature": "subscribe(eventName: InputEventKind, fn: (e: PointerEvent) => void): () => void;", + "signature": "subscribe(eventName: InputEventKind, fn: (e: LocalPointerEvent) => void): () => void;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -8749,7 +8748,7 @@ ], "isOptional": false, "isSpread": false, - "type": "(e: PointerEvent) => void" + "type": "(e: LocalPointerEvent) => void" } }, "deprecatedMessage": [], @@ -8774,7 +8773,7 @@ }, "unsubscribe": { "kind": "method", - "signature": "unsubscribe(eventName: InputEventKind, fn: (e: PointerEvent) => void): void;", + "signature": "unsubscribe(eventName: InputEventKind, fn: (e: LocalPointerEvent) => void): void;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -8805,7 +8804,7 @@ ], "isOptional": false, "isSpread": false, - "type": "(e: PointerEvent) => void" + "type": "(e: LocalPointerEvent) => void" } }, "deprecatedMessage": [], @@ -15501,6 +15500,28 @@ } } }, + "OnPointerDown": { + "kind": "class", + "extends": "PointerEventComponent", + "implements": "", + "typeParameters": [], + "deprecatedMessage": [], + "summary": [], + "remarks": [], + "isBeta": false, + "isSealed": false + }, + "OnPointerUp": { + "kind": "class", + "extends": "PointerEventComponent", + "implements": "", + "typeParameters": [], + "deprecatedMessage": [], + "summary": [], + "remarks": [], + "isBeta": false, + "isSealed": false + }, "OnUUIDEvent": { "kind": "class", "extends": "ObservableComponent", @@ -17264,6 +17285,75 @@ "remarks": [], "isBeta": false }, + "PointerEventComponent": { + "kind": "class", + "extends": "", + "implements": "", + "typeParameters": [], + "deprecatedMessage": [], + "summary": [], + "remarks": [], + "isBeta": false, + "isSealed": false, + "members": { + "__constructor": { + "kind": "constructor", + "signature": "constructor(callback: (event: LocalPointerEvent) => void);", + "parameters": { + "callback": { + "name": "callback", + "description": [], + "isOptional": false, + "isSpread": false, + "type": "(event: LocalPointerEvent) => void" + } + }, + "deprecatedMessage": [], + "summary": [ + { + "kind": "text", + "text": "Constructs a new instance of the " + }, + { + "kind": "api-link", + "elements": [ + { + "kind": "text", + "text": "PointerEventComponent" + } + ], + "target": { + "scopeName": "", + "packageName": "decentraland-ecs", + "exportName": "PointerEventComponent", + "memberName": "" + } + }, + { + "kind": "text", + "text": " class" + } + ], + "remarks": [] + }, + "callback": { + "kind": "property", + "signature": "readonly callback: (event: LocalPointerEvent) => void;", + "isOptional": false, + "isReadOnly": true, + "isStatic": false, + "type": "(event: LocalPointerEvent) => void", + "deprecatedMessage": [], + "summary": [], + "remarks": [], + "isBeta": false, + "isSealed": false, + "isVirtual": false, + "isOverride": false, + "isEventProperty": false + } + } + }, "Quaternion": { "kind": "class", "extends": "", @@ -17368,7 +17458,7 @@ }, "Angle": { "kind": "method", - "signature": "static Angle(quat1: Quaternion, quat2: Quaternion): number;", + "signature": "static Angle(quat1: ReadOnlyQuaternion, quat2: ReadOnlyQuaternion): number;", "accessModifier": "", "isOptional": false, "isStatic": true, @@ -17387,7 +17477,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "quat2": { "name": "quat2", @@ -17399,7 +17489,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" } }, "deprecatedMessage": [], @@ -17451,7 +17541,7 @@ }, "AreClose": { "kind": "method", - "signature": "static AreClose(quat0: Quaternion, quat1: Quaternion): boolean;", + "signature": "static AreClose(quat0: ReadOnlyQuaternion, quat1: ReadOnlyQuaternion): boolean;", "accessModifier": "", "isOptional": false, "isStatic": true, @@ -17475,7 +17565,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "quat1": { "name": "quat1", @@ -17487,7 +17577,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" } }, "deprecatedMessage": [], @@ -17663,7 +17753,7 @@ }, "copyFrom": { "kind": "method", - "signature": "copyFrom(other: Quaternion): Quaternion;", + "signature": "copyFrom(other: ReadOnlyQuaternion): Quaternion;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -17687,7 +17777,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" } }, "deprecatedMessage": [], @@ -17783,7 +17873,7 @@ }, "Dot": { "kind": "method", - "signature": "static Dot(left: Quaternion, right: Quaternion): number;", + "signature": "static Dot(left: ReadOnlyQuaternion, right: ReadOnlyQuaternion): number;", "accessModifier": "", "isOptional": false, "isStatic": true, @@ -17807,7 +17897,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "right": { "name": "right", @@ -17819,7 +17909,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" } }, "deprecatedMessage": [], @@ -17837,7 +17927,7 @@ }, "equals": { "kind": "method", - "signature": "equals(otherQuaternion: Quaternion): boolean;", + "signature": "equals(otherQuaternion: ReadOnlyQuaternion): boolean;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -17861,7 +17951,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" } }, "deprecatedMessage": [], @@ -18308,7 +18398,7 @@ }, "Hermite": { "kind": "method", - "signature": "static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;", + "signature": "static Hermite(value1: ReadOnlyQuaternion, tangent1: ReadOnlyQuaternion, value2: ReadOnlyQuaternion, tangent2: ReadOnlyQuaternion, amount: number): Quaternion;", "accessModifier": "", "isOptional": false, "isStatic": true, @@ -18332,7 +18422,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "tangent1": { "name": "tangent1", @@ -18344,7 +18434,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "value2": { "name": "value2", @@ -18356,7 +18446,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "tangent2": { "name": "tangent2", @@ -18368,7 +18458,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "amount": { "name": "amount", @@ -18461,7 +18551,7 @@ }, "IsIdentity": { "kind": "method", - "signature": "static IsIdentity(quaternion: Quaternion): boolean;", + "signature": "static IsIdentity(quaternion: ReadOnlyQuaternion): boolean;", "accessModifier": "", "isOptional": false, "isStatic": true, @@ -18485,7 +18575,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" } }, "deprecatedMessage": [], @@ -18594,7 +18684,7 @@ }, "multiply": { "kind": "method", - "signature": "multiply(q1: Quaternion): Quaternion;", + "signature": "multiply(q1: ReadOnlyQuaternion): Quaternion;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -18618,7 +18708,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" } }, "deprecatedMessage": [], @@ -18636,7 +18726,7 @@ }, "multiplyInPlace": { "kind": "method", - "signature": "multiplyInPlace(q1: Quaternion): Quaternion;", + "signature": "multiplyInPlace(q1: ReadOnlyQuaternion): Quaternion;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -18660,7 +18750,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" } }, "deprecatedMessage": [], @@ -18678,7 +18768,7 @@ }, "multiplyToRef": { "kind": "method", - "signature": "multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;", + "signature": "multiplyToRef(q1: ReadOnlyQuaternion, result: Quaternion): Quaternion;", "accessModifier": "", "isOptional": false, "isStatic": false, @@ -18702,7 +18792,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "result": { "name": "result", @@ -18782,7 +18872,7 @@ }, "RotateTowards": { "kind": "method", - "signature": "static RotateTowards(from: Quaternion, to: Quaternion, maxDegreesDelta: number): Quaternion;", + "signature": "static RotateTowards(from: ReadOnlyQuaternion, to: Quaternion, maxDegreesDelta: number): Quaternion;", "accessModifier": "", "isOptional": false, "isStatic": true, @@ -18801,7 +18891,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "to": { "name": "to", @@ -19762,7 +19852,7 @@ }, "Slerp": { "kind": "method", - "signature": "static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;", + "signature": "static Slerp(left: ReadOnlyQuaternion, right: ReadOnlyQuaternion, amount: number): Quaternion;", "accessModifier": "", "isOptional": false, "isStatic": true, @@ -19786,7 +19876,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "right": { "name": "right", @@ -19798,7 +19888,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "amount": { "name": "amount", @@ -19828,7 +19918,7 @@ }, "SlerpToRef": { "kind": "method", - "signature": "static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;", + "signature": "static SlerpToRef(left: ReadOnlyQuaternion, right: ReadOnlyQuaternion, amount: number, result: Quaternion): void;", "accessModifier": "", "isOptional": false, "isStatic": true, @@ -19847,7 +19937,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "right": { "name": "right", @@ -19859,7 +19949,7 @@ ], "isOptional": false, "isSpread": false, - "type": "Quaternion" + "type": "ReadOnlyQuaternion" }, "amount": { "name": "amount", diff --git a/packages/decentraland-ecs/types/dcl/index.d.ts b/packages/decentraland-ecs/types/dcl/index.d.ts index 462533f5c..b85ce4657 100644 --- a/packages/decentraland-ecs/types/dcl/index.d.ts +++ b/packages/decentraland-ecs/types/dcl/index.d.ts @@ -1,5265 +1,5272 @@ -/** - * Defines angle representation - * @public - */ -declare class Angle { - private _radians - /** - * Creates an Angle object of "radians" radians (float). - */ - constructor(radians: number) - /** - * Gets a new Angle object valued with the angle value in radians between the two given vectors - * @param a - defines first vector - * @param b - defines second vector - * @returns a new Angle - */ - static BetweenTwoPoints(a: Vector2, b: Vector2): Angle - /** - * Gets a new Angle object from the given float in radians - * @param radians - defines the angle value in radians - * @returns a new Angle - */ - static FromRadians(radians: number): Angle - /** - * Gets a new Angle object from the given float in degrees - * @param degrees - defines the angle value in degrees - * @returns a new Angle - */ - static FromDegrees(degrees: number): Angle - /** - * Get value in degrees - * @returns the Angle value in degrees (float) - */ - degrees(): number - /** - * Get value in radians - * @returns the Angle value in radians (float) - */ - radians(): number -} - -/** - * @public - */ -declare class AnimationClip extends ObservableComponent { - /** - * Name of the animation in the model - */ - readonly clip: string - /** - * Does the animation loop?, default: true - */ - looping: boolean - /** - * Weight of the animation, values from 0 to 1, used to blend several animations. default: 1 - */ - weight: number - /** - * Is the animation playing? default: true - */ - playing: boolean - /** - * The animation speed - */ - speed: number - constructor(clip: string, params?: AnimationParams) - /** - * Sets the clip parameters - */ - setParams(params: AnimationParams): void - /** - * Starts the animation - */ - play(): void - /** - * Pauses the animation - */ - pause(): void -} - -declare type AnimationParams = { - looping?: boolean - speed?: number - weight?: number -} - -/** - * @public - */ -declare class Animator extends Shape { - private states - /** - * Adds an AnimationClip to the animation lists. - */ - addClip(clip: AnimationClip): void - /** - * Gets the animation clip instance for the specified clip name. - * If the clip doesn't exist a new one will be created. - */ - getClip(clipName: string): AnimationClip -} - -/** - * This represents an arc in a 2d space. - * @public - */ -declare class Arc2 { - /** Defines the start point of the arc */ - startPoint: Vector2 - /** Defines the mid point of the arc */ - midPoint: Vector2 - /** Defines the end point of the arc */ - endPoint: Vector2 - /** - * Defines the center point of the arc. - */ - centerPoint: Vector2 - /** - * Defines the radius of the arc. - */ - radius: number - /** - * Defines the angle of the arc (from mid point to end point). - */ - angle: Angle - /** - * Defines the start angle of the arc (from start point to middle point). - */ - startAngle: Angle - /** - * Defines the orientation of the arc (clock wise/counter clock wise). - */ - orientation: Orientation - /** - * Creates an Arc object from the three given points : start, middle and end. - * @param startPoint - Defines the start point of the arc - * @param midPoint - Defines the midlle point of the arc - * @param endPoint - Defines the end point of the arc - */ - constructor( - /** Defines the start point of the arc */ - startPoint: Vector2, - /** Defines the mid point of the arc */ - midPoint: Vector2, - /** Defines the end point of the arc */ - endPoint: Vector2 - ) -} - -/** - * @public - */ -declare class AudioClip extends ObservableComponent { - readonly url: string - /** - * Is this clip looping by default? - */ - loop: boolean - /** - * Clip's master volume. This volume affects all the AudioSources. - * Valid ranges from 0 to 1 - */ - volume: number - constructor(url: string) -} - -/** - * @public - */ -declare class AudioSource extends ObservableComponent { - readonly audioClip: AudioClip - readonly audioClipId: string - /** - * Is this clip looping by default? - */ - loop: boolean - /** - * Clip's master volume. This volume affects all the AudioSources. - * Valid ranges from 0 to 1 - */ - volume: number - /** - * Is this AudioSource playing? - */ - playing: boolean - /** - * Pitch, default: 1.0, range from 0.0 to MaxFloat - */ - pitch: number - constructor(audioClip: AudioClip) - /** - * Disables the looping and plays the current source once. - * If the sound was playing, it stops and starts over. - */ - playOnce(): void -} - -/** - * Defines the 3 main axes - * @public - */ -declare class Axis { - /** X axis */ - static X: Vector3 - /** Y axis */ - static Y: Vector3 - /** Z axis */ - static Z: Vector3 -} - -/** - * @public - */ -declare class BasicMaterial extends ObservableComponent { - /** - * The source of the texture image. - */ - texture: string - /** - * A number between 0 and 1. - * Any pixel with an alpha lower than this value will be shown as transparent. - */ - alphaTest: number - /** - * Enables crisper images based on the provided sampling mode. - * | Value | Type | - * |-------|-----------| - * | 1 | NEAREST | - * | 2 | BILINEAR | - * | 3 | TRILINEAR | - */ - samplingMode: number - /** - * Enables texture wrapping for this material. - * | Value | Type | - * |-------|-----------| - * | 1 | CLAMP | - * | 2 | WRAP | - * | 3 | MIRROR | - */ - wrap: number -} - -/** - * Class used to represent a Bezier curve - * @public - */ -declare class BezierCurve { - /** - * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats - * @param t - defines the time - * @param x1 - defines the left coordinate on X axis - * @param y1 - defines the left coordinate on Y axis - * @param x2 - defines the right coordinate on X axis - * @param y2 - defines the right coordinate on Y axis - * @returns the interpolated value - */ - static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number -} - -/** - * Billboard defines a behavior that makes the entity face the camera in any moment. - * @public - */ -declare class Billboard extends ObservableComponent { - x: boolean - y: boolean - z: boolean - constructor(x?: boolean, y?: boolean, z?: boolean) -} - -/** - * @public - */ -declare class BoxShape extends Shape {} - -/** - * @public - */ -declare class Camera { - static readonly instance: Camera - readonly position: Vector3 - readonly rotation: Quaternion - constructor() -} - -/** - * @public - */ -declare class CircleShape extends Shape { - segments?: number - arc?: number -} - -/** - * Class used to hold a RBG color - * @public - */ -declare class Color3 { - /** - * Defines the red component (between 0 and 1, default is 0) - */ - r: number - /** - * Defines the green component (between 0 and 1, default is 0) - */ - g: number - /** - * Defines the blue component (between 0 and 1, default is 0) - */ - b: number - /** - * Creates a new Color3 object from red, green, blue values, all between 0 and 1 - * @param r - defines the red component (between 0 and 1, default is 0) - * @param g - defines the green component (between 0 and 1, default is 0) - * @param b - defines the blue component (between 0 and 1, default is 0) - */ - constructor( - /** - * Defines the red component (between 0 and 1, default is 0) - */ - r?: number, - /** - * Defines the green component (between 0 and 1, default is 0) - */ - g?: number, - /** - * Defines the blue component (between 0 and 1, default is 0) - */ - b?: number - ) - /** - * Creates a new Color3 from the string containing valid hexadecimal values - * @param hex - defines a string containing valid hexadecimal values - * @returns a new Color3 object - */ - static FromHexString(hex: string): Color3 - /** - * Creates a new Vector3 from the starting index of the given array - * @param array - defines the source array - * @param offset - defines an offset in the source array - * @returns a new Color3 object - */ - static FromArray(array: ArrayLike, offset?: number): Color3 - /** - * Creates a new Color3 from integer values (less than 256) - * @param r - defines the red component to read from (value between 0 and 255) - * @param g - defines the green component to read from (value between 0 and 255) - * @param b - defines the blue component to read from (value between 0 and 255) - * @returns a new Color3 object - */ - static FromInts(r: number, g: number, b: number): Color3 - /** - * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3 - * @param start - defines the start Color3 value - * @param end - defines the end Color3 value - * @param amount - defines the gradient value between start and end - * @returns a new Color3 object - */ - static Lerp(start: Color3, end: Color3, amount: number): Color3 - /** - * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3 - * @param left - defines the start value - * @param right - defines the end value - * @param amount - defines the gradient factor - * @param result - defines the Color3 object where to store the result - */ - static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void - /** - * Returns a Color3 value containing a red color - * @returns a new Color3 object - */ - static Red(): Color3 - /** - * Returns a Color3 value containing a green color - * @returns a new Color3 object - */ - static Green(): Color3 - /** - * Returns a Color3 value containing a blue color - * @returns a new Color3 object - */ - static Blue(): Color3 - /** - * Returns a Color3 value containing a black color - * @returns a new Color3 object - */ - static Black(): Color3 - /** - * Returns a Color3 value containing a white color - * @returns a new Color3 object - */ - static White(): Color3 - /** - * Returns a Color3 value containing a purple color - * @returns a new Color3 object - */ - static Purple(): Color3 - /** - * Returns a Color3 value containing a magenta color - * @returns a new Color3 object - */ - static Magenta(): Color3 - /** - * Returns a Color3 value containing a yellow color - * @returns a new Color3 object - */ - static Yellow(): Color3 - /** - * Returns a Color3 value containing a gray color - * @returns a new Color3 object - */ - static Gray(): Color3 - /** - * Returns a Color3 value containing a teal color - * @returns a new Color3 object - */ - static Teal(): Color3 - /** - * Returns a Color3 value containing a random color - * @returns a new Color3 object - */ - static Random(): Color3 - /** - * Creates a string with the Color3 current values - * @returns the string representation of the Color3 object - */ - toString(): string - /** - * Returns the string "Color3" - * @returns "Color3" - */ - getClassName(): string - /** - * Compute the Color3 hash code - * @returns an unique number that can be used to hash Color3 objects - */ - getHashCode(): number - /** - * Stores in the given array from the given starting index the red, green, blue values as successive elements - * @param array - defines the array where to store the r,g,b components - * @param index - defines an optional index in the target array to define where to start storing values - * @returns the current Color3 object - */ - toArray(array: FloatArray, index?: number): Color3 - /** - * Returns a new Color4 object from the current Color3 and the given alpha - * @param alpha - defines the alpha component on the new Color4 object (default is 1) - * @returns a new Color4 object - */ - toColor4(alpha?: number): Color4 - /** - * Returns a new array populated with 3 numeric elements : red, green and blue values - * @returns the new array - */ - asArray(): number[] - /** - * Returns the luminance value - * @returns a float value - */ - toLuminance(): number - /** - * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object - * @param otherColor - defines the second operand - * @returns the new Color3 object - */ - multiply(otherColor: Color3): Color3 - /** - * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result" - * @param otherColor - defines the second operand - * @param result - defines the Color3 object where to store the result - * @returns the current Color3 - */ - multiplyToRef(otherColor: Color3, result: Color3): Color3 - /** - * Determines equality between Color3 objects - * @param otherColor - defines the second operand - * @returns true if the rgb values are equal to the given ones - */ - equals(otherColor: Color3): boolean - /** - * Determines equality between the current Color3 object and a set of r,b,g values - * @param r - defines the red component to check - * @param g - defines the green component to check - * @param b - defines the blue component to check - * @returns true if the rgb values are equal to the given ones - */ - equalsFloats(r: number, g: number, b: number): boolean - /** - * Multiplies in place each rgb value by scale - * @param scale - defines the scaling factor - * @returns the updated Color3 - */ - scale(scale: number): Color3 - /** - * Multiplies the rgb values by scale and stores the result into "result" - * @param scale - defines the scaling factor - * @param result - defines the Color3 object where to store the result - * @returns the unmodified current Color3 - */ - scaleToRef(scale: number, result: Color3): Color3 - /** - * Scale the current Color3 values by a factor and add the result to a given Color3 - * @param scale - defines the scale factor - * @param result - defines color to store the result into - * @returns the unmodified current Color3 - */ - scaleAndAddToRef(scale: number, result: Color3): Color3 - /** - * Clamps the rgb values by the min and max values and stores the result into "result" - * @param min - defines minimum clamping value (default is 0) - * @param max - defines maximum clamping value (default is 1) - * @param result - defines color to store the result into - * @returns the original Color3 - */ - clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3 - /** - * Creates a new Color3 set with the added values of the current Color3 and of the given one - * @param otherColor - defines the second operand - * @returns the new Color3 - */ - add(otherColor: Color3): Color3 - /** - * Stores the result of the addition of the current Color3 and given one rgb values into "result" - * @param otherColor - defines the second operand - * @param result - defines Color3 object to store the result into - * @returns the unmodified current Color3 - */ - addToRef(otherColor: Color3, result: Color3): Color3 - /** - * Returns a new Color3 set with the subtracted values of the given one from the current Color3 - * @param otherColor - defines the second operand - * @returns the new Color3 - */ - subtract(otherColor: Color3): Color3 - /** - * Stores the result of the subtraction of given one from the current Color3 rgb values into "result" - * @param otherColor - defines the second operand - * @param result - defines Color3 object to store the result into - * @returns the unmodified current Color3 - */ - subtractToRef(otherColor: Color3, result: Color3): Color3 - /** - * Copy the current object - * @returns a new Color3 copied the current one - */ - clone(): Color3 - /** - * Copies the rgb values from the source in the current Color3 - * @param source - defines the source Color3 object - * @returns the updated Color3 object - */ - copyFrom(source: Color3): Color3 - /** - * Updates the Color3 rgb values from the given floats - * @param r - defines the red component to read from - * @param g - defines the green component to read from - * @param b - defines the blue component to read from - * @returns the current Color3 object - */ - copyFromFloats(r: number, g: number, b: number): Color3 - /** - * Updates the Color3 rgb values from the given floats - * @param r - defines the red component to read from - * @param g - defines the green component to read from - * @param b - defines the blue component to read from - * @returns the current Color3 object - */ - set(r: number, g: number, b: number): Color3 - /** - * Compute the Color3 hexadecimal code as a string - * @returns a string containing the hexadecimal representation of the Color3 object - */ - toHexString(): string - /** - * Computes a new Color3 converted from the current one to linear space - * @returns a new Color3 object - */ - toLinearSpace(): Color3 - /** - * Converts the Color3 values to linear space and stores the result in "convertedColor" - * @param convertedColor - defines the Color3 object where to store the linear space version - * @returns the unmodified Color3 - */ - toLinearSpaceToRef(convertedColor: Color3): Color3 - /** - * Computes a new Color3 converted from the current one to gamma space - * @returns a new Color3 object - */ - toGammaSpace(): Color3 - /** - * Converts the Color3 values to gamma space and stores the result in "convertedColor" - * @param convertedColor - defines the Color3 object where to store the gamma space version - * @returns the unmodified Color3 - */ - toGammaSpaceToRef(convertedColor: Color3): Color3 - /** - * Serializes Color3 - */ - toJSON(): string -} - -/** - * Class used to hold a RBGA color - * @public - */ -declare class Color4 { - /** - * Defines the red component (between 0 and 1, default is 0) - */ - r: number - /** - * Defines the green component (between 0 and 1, default is 0) - */ - g: number - /** - * Defines the blue component (between 0 and 1, default is 0) - */ - b: number - /** - * Defines the alpha component (between 0 and 1, default is 1) - */ - a: number - /** - * Creates a new Color4 object from red, green, blue values, all between 0 and 1 - * @param r - defines the red component (between 0 and 1, default is 0) - * @param g - defines the green component (between 0 and 1, default is 0) - * @param b - defines the blue component (between 0 and 1, default is 0) - * @param a - defines the alpha component (between 0 and 1, default is 1) - */ - constructor( - /** - * Defines the red component (between 0 and 1, default is 0) - */ - r?: number, - /** - * Defines the green component (between 0 and 1, default is 0) - */ - g?: number, - /** - * Defines the blue component (between 0 and 1, default is 0) - */ - b?: number, - /** - * Defines the alpha component (between 0 and 1, default is 1) - */ - a?: number - ) - /** - * Creates a new Color4 from the string containing valid hexadecimal values - * @param hex - defines a string containing valid hexadecimal values - * @returns a new Color4 object - */ - static FromHexString(hex: string): Color4 - /** - * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object - * @param left - defines the start value - * @param right - defines the end value - * @param amount - defines the gradient factor - * @returns a new Color4 object - */ - static Lerp(left: Color4, right: Color4, amount: number): Color4 - /** - * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object - * @param left - defines the start value - * @param right - defines the end value - * @param amount - defines the gradient factor - * @param result - defines the Color4 object where to store data - */ - static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void - /** - * Creates a new Color4 from a Color3 and an alpha value - * @param color3 - defines the source Color3 to read from - * @param alpha - defines the alpha component (1.0 by default) - * @returns a new Color4 object - */ - static FromColor3(color3: Color3, alpha?: number): Color4 - /** - * Creates a new Color4 from the starting index element of the given array - * @param array - defines the source array to read from - * @param offset - defines the offset in the source array - * @returns a new Color4 object - */ - static FromArray(array: ArrayLike, offset?: number): Color4 - /** - * Creates a new Color3 from integer values (less than 256) - * @param r - defines the red component to read from (value between 0 and 255) - * @param g - defines the green component to read from (value between 0 and 255) - * @param b - defines the blue component to read from (value between 0 and 255) - * @param a - defines the alpha component to read from (value between 0 and 255) - * @returns a new Color3 object - */ - static FromInts(r: number, g: number, b: number, a: number): Color4 - /** - * Check the content of a given array and convert it to an array containing RGBA data - * If the original array was already containing count * 4 values then it is returned directly - * @param colors - defines the array to check - * @param count - defines the number of RGBA data to expect - * @returns an array containing count * 4 values (RGBA) - */ - static CheckColors4(colors: number[], count: number): number[] - /** - * Adds in place the given Color4 values to the current Color4 object - * @param right - defines the second operand - * @returns the current updated Color4 object - */ - addInPlace(right: Color4): Color4 - /** - * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values - * @returns the new array - */ - asArray(): number[] - /** - * Stores from the starting index in the given array the Color4 successive values - * @param array - defines the array where to store the r,g,b components - * @param index - defines an optional index in the target array to define where to start storing values - * @returns the current Color4 object - */ - toArray(array: number[], index?: number): Color4 - /** - * Creates a new Color4 set with the added values of the current Color4 and of the given one - * @param right - defines the second operand - * @returns a new Color4 object - */ - add(right: Color4): Color4 - /** - * Creates a new Color4 set with the subtracted values of the given one from the current Color4 - * @param right - defines the second operand - * @returns a new Color4 object - */ - subtract(right: Color4): Color4 - /** - * Subtracts the given ones from the current Color4 values and stores the results in "result" - * @param right - defines the second operand - * @param result - defines the Color4 object where to store the result - * @returns the current Color4 object - */ - subtractToRef(right: Color4, result: Color4): Color4 - /** - * Creates a new Color4 with the current Color4 values multiplied by scale - * @param scale - defines the scaling factor to apply - * @returns a new Color4 object - */ - scale(scale: number): Color4 - /** - * Multiplies the current Color4 values by scale and stores the result in "result" - * @param scale - defines the scaling factor to apply - * @param result - defines the Color4 object where to store the result - * @returns the current unmodified Color4 - */ - scaleToRef(scale: number, result: Color4): Color4 - /** - * Scale the current Color4 values by a factor and add the result to a given Color4 - * @param scale - defines the scale factor - * @param result - defines the Color4 object where to store the result - * @returns the unmodified current Color4 - */ - scaleAndAddToRef(scale: number, result: Color4): Color4 - /** - * Clamps the rgb values by the min and max values and stores the result into "result" - * @param min - defines minimum clamping value (default is 0) - * @param max - defines maximum clamping value (default is 1) - * @param result - defines color to store the result into. - * @returns the cuurent Color4 - */ - clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4 - /** - * Multipy an Color4 value by another and return a new Color4 object - * @param color - defines the Color4 value to multiply by - * @returns a new Color4 object - */ - multiply(color: Color4): Color4 - /** - * Multipy a Color4 value by another and push the result in a reference value - * @param color - defines the Color4 value to multiply by - * @param result - defines the Color4 to fill the result in - * @returns the result Color4 - */ - multiplyToRef(color: Color4, result: Color4): Color4 - /** - * Creates a string with the Color4 current values - * @returns the string representation of the Color4 object - */ - toString(): string - /** - * Returns the string "Color4" - * @returns "Color4" - */ - getClassName(): string - /** - * Compute the Color4 hash code - * @returns an unique number that can be used to hash Color4 objects - */ - getHashCode(): number - /** - * Creates a new Color4 copied from the current one - * @returns a new Color4 object - */ - clone(): Color4 - /** - * Copies the given Color4 values into the current one - * @param source - defines the source Color4 object - * @returns the current updated Color4 object - */ - copyFrom(source: Color4): Color4 - /** - * Copies the given float values into the current one - * @param r - defines the red component to read from - * @param g - defines the green component to read from - * @param b - defines the blue component to read from - * @param a - defines the alpha component to read from - * @returns the current updated Color4 object - */ - copyFromFloats(r: number, g: number, b: number, a: number): Color4 - /** - * Copies the given float values into the current one - * @param r - defines the red component to read from - * @param g - defines the green component to read from - * @param b - defines the blue component to read from - * @param a - defines the alpha component to read from - * @returns the current updated Color4 object - */ - set(r: number, g: number, b: number, a: number): Color4 - /** - * Compute the Color4 hexadecimal code as a string - * @returns a string containing the hexadecimal representation of the Color4 object - */ - toHexString(): string - /** - * Computes a new Color4 converted from the current one to linear space - * @returns a new Color4 object - */ - toLinearSpace(): Color4 - /** - * Converts the Color4 values to linear space and stores the result in "convertedColor" - * @param convertedColor - defines the Color4 object where to store the linear space version - * @returns the unmodified Color4 - */ - toLinearSpaceToRef(convertedColor: Color4): Color4 - /** - * Computes a new Color4 converted from the current one to gamma space - * @returns a new Color4 object - */ - toGammaSpace(): Color4 - /** - * Converts the Color4 values to gamma space and stores the result in "convertedColor" - * @param convertedColor - defines the Color4 object where to store the gamma space version - * @returns the unmodified Color4 - */ - toGammaSpaceToRef(convertedColor: Color4): Color4 -} - -/** - * @public - */ -declare function Component( - componentName: string, - classId?: number -): >(target: TFunction) => void | TFunction - -/** - * @public - */ -declare class ComponentAdded { - entity: Entity - componentName: string - classId: number | null - constructor(entity: Entity, componentName: string, classId: number | null) -} - -/** - * @public - */ -declare interface ComponentConstructor { - isComponent?: boolean - originalClassName?: string - new (...args: any[]): T -} - -/** - * @public - */ -declare class ComponentGroup { - readonly entities: ReadonlyArray - readonly requires: ReadonlyArray> - readonly requiresNames: ReadonlyArray - active: boolean - private _requiresNames - constructor(...requires: ComponentConstructor[]) - hasEntity(entity: Entity): boolean -} - -/** - * @public - */ -declare interface ComponentLike {} - -/** - * @public - */ -declare class ComponentRemoved { - entity: Entity - componentName: string - component: ComponentLike - constructor(entity: Entity, componentName: string, component: ComponentLike) -} - -/** - * @public - */ -declare class ConeShape extends Shape { - /** - * The radius of the top of a truncated cone. Defaults to 0. - */ - radiusTop: number - /** - * The radius of the base of the cone. Defaults to 1. - */ - radiusBottom: number - /** - * Sets the number of rings along the cone height (positive integer). Defaults to 1. - */ - segmentsHeight: number - /** - * Sets the number of cone sides (positive integer). Defaults to 36. - */ - segmentsRadial: number - /** - * Adds two extra faces per subdivision to enclose the cone around its height axis. - * Defaults to false. - */ - openEnded: boolean - /** - * Sets the radius of the top and bottom caps at once. - * - * Properties `radiusTop` and `radiusBottom` are prioritized over this one. - */ - radius: number | null - /** - * Sets the ratio (max 1) to apply to the circumference to slice the cone. Defaults to 360. - */ - arc: number -} - -/** - * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. - * A Curve3 is designed from a series of successive Vector3. - * {@link https://doc.babylonjs.com/how_to/how_to_use_curve3 } - * @public - */ -declare class Curve3 { - private _points - private _length - /** - * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. - * A Curve3 is designed from a series of successive Vector3. - * {@link http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object | Tutorial } - * @param points - points which make up the curve - */ - constructor(points: Vector3[]) - /** - * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve - * @param v0 - (Vector3) the origin point of the Quadratic Bezier - * @param v1 - (Vector3) the control point - * @param v2 - (Vector3) the end point of the Quadratic Bezier - * @param nbPoints - (integer) the wanted number of points in the curve - * @returns the created Curve3 - */ - static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3 - /** - * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve - * @param v0 - (Vector3) the origin point of the Cubic Bezier - * @param v1 - (Vector3) the first control point - * @param v2 - (Vector3) the second control point - * @param v3 - (Vector3) the end point of the Cubic Bezier - * @param nbPoints - (integer) the wanted number of points in the curve - * @returns the created Curve3 - */ - static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3 - /** - * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline - * @param p1 - (Vector3) the origin point of the Hermite Spline - * @param t1 - (Vector3) the tangent vector at the origin point - * @param p2 - (Vector3) the end point of the Hermite Spline - * @param t2 - (Vector3) the tangent vector at the end point - * @param nbPoints - (integer) the wanted number of points in the curve - * @returns the created Curve3 - */ - static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3 - /** - * Returns a Curve3 object along a CatmullRom Spline curve : - * @param points - (array of Vector3) the points the spline must pass through. At least, four points required - * @param nbPoints - (integer) the wanted number of points between each curve control points - * @param closed - (boolean) optional with default false, when true forms a closed loop from the points - * @returns the created Curve3 - */ - static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3 - /** - * @returns the Curve3 stored array of successive Vector3 - */ - getPoints(): Vector3[] - /** - * @returns the computed length (float) of the curve. - */ - length(): number - /** - * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); - * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. - * curveA and curveB keep unchanged. - * @param curve - the curve to continue from this curve - * @returns the newly constructed curve - */ - continue(curve: Curve3): Curve3 - private _computeLength -} - -/** - * @public - */ -declare class CylinderShape extends Shape { - /** - * The radius of the top of the cylinder. Defaults to 0. - */ - radiusTop: number - /** - * The radius of the base of the cylinder. Defaults to 1. - */ - radiusBottom: number - /** - * Sets the number of rings along the cylinder height (positive integer). Defaults to 1. - */ - segmentsHeight: number - /** - * Sets the number of cylinder sides (positive integer). Defaults to 36. - */ - segmentsRadial: number - /** - * Adds two extra faces per subdivision to enclose the cylinder around its height axis. - * Defaults to false. - */ - openEnded: boolean - /** - * Sets the radius of the top and bottom caps at once. - * - * Properties `radiusTop` and `radiusBottom` are prioritized over this one. - */ - radius: number | null - /** - * Sets the ratio (max 1) to apply to the circumference to slice the cylinder. Defaults to 360. - */ - arc: number -} - -declare const DEG2RAD: number - -/** - * @public - */ -declare function DisposableComponent( - componentName: string, - classId: number -): >(target: TFunction) => void | TFunction - -/** - * @public - */ -declare interface DisposableComponentConstructor { - isComponent?: boolean - isDisposableComponent?: true - originalClassName?: string - new (...args: any[]): T -} - -/** - * @public - */ -declare class DisposableComponentCreated { - componentId: string - componentName: string - classId: number - constructor(componentId: string, componentName: string, classId: number) -} - -/** - * @public - */ -declare interface DisposableComponentLike extends ComponentLike { - onDispose?(): void -} - -/** - * @public - */ -declare class DisposableComponentRemoved { - componentId: string - constructor(componentId: string) -} - -/** - * @public - */ -declare class DisposableComponentUpdated { - componentId: string - component: DisposableComponentLike - constructor(componentId: string, component: DisposableComponentLike) -} - -/** - * @public - */ -declare class Engine { - readonly eventManager: EventManager - readonly rootEntity: Entity - private readonly _entities - private readonly _disposableComponents - private readonly _componentGroups - private readonly simpleSystems - readonly entities: Readonly> - readonly disposableComponents: Readonly> - constructor() - addEntity(entity: Entity): void - removeEntity(entity: Entity, removeChildren?: boolean, newParent?: Entity): void - addSystem(system: ISystem, priority?: number): void - removeSystem(system: ISystem): void - update(dt: number): void - getEntitiesWithComponent(component: string): Record - getEntitiesWithComponent(component: ComponentConstructor): Record - registerComponent(component: DisposableComponentLike): void - disposeComponent(component: DisposableComponentLike): void - updateComponent(component: DisposableComponentLike): void - getComponentGroup(...requires: ComponentConstructor[]): ComponentGroup - removeComponentGroup(componentGroup: ComponentGroup): void - private registerSystem - private checkRequirementsAndAdd - private checkRequirements - private componentAddedHandler - private componentRemovedHandler -} - -declare type EnginePointerEvent = { - /** Origin of the ray */ - from: { - x: number - y: number - z: number - } - /** Direction vector of the ray (normalized) */ - direction: { - x: number - y: number - z: number - } - /** Length of the ray */ - length: number - /** ID of the pointer that triggered the event */ - pointerId: number -} - -/** - * @public - */ -declare class Entity { - name?: string | undefined - children: Record - eventManager: EventManager | null - alive: boolean - readonly uuid: string - readonly components: Record - constructor(_parent?: Entity | null, name?: string | undefined) - /** - * Adds or replaces a component in the entity. - * @param component - component instance. - */ - set(component: T): void - /** - * Returns a boolean indicating if a component is present in the entity. - * @param component - component class or name - */ - has(component: ComponentConstructor): boolean - /** - * Gets a component, if it doesn't exist, it throws an Error. - * @param component - component class or name - */ - get(component: string): T - get(component: ComponentConstructor): T - /** - * Gets a component, if it doesn't exist, it returns null. - * @param component - component class or name - */ - getOrNull(component: string): T | null - getOrNull(component: ComponentConstructor): T | null - /** - * Gets a component, if it doesn't exist, it creates the component and returns it. - * @param component - component class - */ - getOrCreate( - component: ComponentConstructor & { - new (): T - } - ): T - /** - * Adds a component. If the component already exist, it throws an Error. - * @param component - component instance. - */ - add(component: T): void - /** - * Removes a component instance from the entity. - * @param component - component instance to remove - */ - remove(component: string): void - remove(component: T): void - /** - * Returns true if the entity is already added to the engine. - * Returns false if no engine was defined. - */ - isAddedToEngine(): boolean - /** - * Sets the parent entity - */ - setParent(entity: Entity): void - /** - * Gets the parent entity - */ - getParent(): Entity | null - private readonly identifier - private getCircularAncestor - private registerAsChild -} - -declare const Epsilon = 0.000001 - -/** - * @public - */ -declare class EventManager { - private listeners - addListener(eventClass: IEventConstructor, listener: X, listenerFunction: (this: X, event: T) => void): void - removeListener(listener: X, eventClass: IEventConstructor): boolean - fireEvent(event: T): void -} - -declare type FloatArray = number[] - -/** - * Reprasents a camera frustum - * @beta - */ -declare class Frustum { - /** - * Gets the planes representing the frustum - * @param transform - matrix to be applied to the returned planes - * @returns a new array of 6 Frustum planes computed by the given transformation matrix. - */ - static GetPlanes(transform: Matrix): Plane[] - /** - * Gets the near frustum plane transformed by the transform matrix - * @param transform - transformation matrix to be applied to the resulting frustum plane - * @param frustumPlane - the resuling frustum plane - */ - static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void - /** - * Gets the far frustum plane transformed by the transform matrix - * @param transform - transformation matrix to be applied to the resulting frustum plane - * @param frustumPlane - the resuling frustum plane - */ - static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void - /** - * Gets the left frustum plane transformed by the transform matrix - * @param transform - transformation matrix to be applied to the resulting frustum plane - * @param frustumPlane - the resuling frustum plane - */ - static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void - /** - * Gets the right frustum plane transformed by the transform matrix - * @param transform - transformation matrix to be applied to the resulting frustum plane - * @param frustumPlane - the resuling frustum plane - */ - static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void - /** - * Gets the top frustum plane transformed by the transform matrix - * @param transform - transformation matrix to be applied to the resulting frustum plane - * @param frustumPlane - the resuling frustum plane - */ - static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void - /** - * Gets the bottom frustum plane transformed by the transform matrix - * @param transform - transformation matrix to be applied to the resulting frustum plane - * @param frustumPlane - the resuling frustum plane - */ - static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void - /** - * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix. - * @param transform - transformation matrix to be applied to the resulting frustum planes - * @param frustumPlanes - the resuling frustum planes - */ - static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void -} - -/** - * @public - */ -declare class GLTFShape extends Shape { - readonly src: string - constructor(src: string) -} - -/** - * Gizmo identifiers - * @beta - */ -declare enum Gizmo { - MOVE = 'MOVE', - ROTATE = 'ROTATE', - SCALE = 'SCALE', - NONE = 'NONE' -} - -declare type GizmoDragEndEvent = { - type: 'gizmoDragEnded' - transform: { - position: ReadOnlyVector3 - rotation: ReadOnlyQuaternion - scale: ReadOnlyVector3 - } - entityId: string -} - -declare type GizmoSelectedEvent = { - type: 'gizmoSelected' - gizmoType: 'MOVE' | 'ROTATE' | 'SCALE' - entityId: string -} - -/** - * Enables gizmos in the entity. Gizmos only work in EDITOR, PREVIEW or DEBUG modes. - * @beta - */ -declare class Gizmos extends ObservableComponent { - /** - * Enable position gizmo - */ - position: boolean - /** - * Enable rotation gizmo - */ - rotation: boolean - /** - * Enable scale gizmo - */ - scale: boolean - /** - * Cycle through gizmos using click. - */ - cycle: boolean - /** - * If cycle is false, this will be the selected gizmo - */ - selectedGizmo?: Gizmo - /** - * Align the gizmos to match the local reference system - */ - localReference: boolean -} - -/** - * @public - */ -declare interface IEventConstructor { - new (...args: any[]): T -} - -declare interface IEvents { - /** - * `positionChanged` is triggered when the position of the camera changes - * This event is throttled to 10 times per second. - */ - positionChanged: { - /** Position relative to the base parcel of the scene */ - position: ReadOnlyVector3 - /** Camera position, this is a absolute world position */ - cameraPosition: ReadOnlyVector3 - /** Eye height, in meters. */ - playerHeight: number - } - /** - * `rotationChanged` is triggered when the rotation of the camera changes. - * This event is throttled to 10 times per second. - */ - rotationChanged: { - /** {X,Y,Z} Degree vector. Same as entities */ - rotation: ReadOnlyVector3 - /** Rotation quaternion, useful in some scenarios. */ - quaternion: ReadOnlyQuaternion - } - /** - * `click` is triggered when a user points and the ray (from mouse or controller) hits the entity. - * Notice: Only entities with ID will be listening for click events. - */ - click: { - /** ID of the entitiy of the event */ - entityId: string - /** ID of the pointer that triggered the event */ - pointerId: number - } - /** - * `pointerUp` is triggered when the user releases an input pointer. - * It could be a VR controller, a touch screen or the mouse. - */ - pointerUp: PointerEvent_2 - /** - * `pointerDown` is triggered when the user press an input pointer. - * It could be a VR controller, a touch screen or the mouse. - */ - pointerDown: PointerEvent_2 - /** - * `chatMessage` is triggered when the user sends a message through chat entity. - */ - chatMessage: { - id: string - sender: string - message: string - isCommand: boolean - } - /** - * `onChange` is triggered when an entity changes its own internal state. - * Dispatched by the `ui-*` entities when their value is changed. It triggers a callback. - * Notice: Only entities with ID will be listening for click events. - */ - onChange: { - value?: any - /** ID of the pointer that triggered the event */ - pointerId?: number - } - /** - * `onFocus` is triggered when an entity focus is active. - * Dispatched by the `ui-input` and `ui-password` entities when the value is changed. - * It triggers a callback. - * - * Notice: Only entities with ID will be listening for click events. - */ - onFocus: { - /** ID of the entitiy of the event */ - entityId: string - /** ID of the pointer that triggered the event */ - pointerId: number - } - /** - * `onBlur` is triggered when an entity loses its focus. - * Dispatched by the `ui-input` and `ui-password` entities when the value is changed. - * It triggers a callback. - * - * Notice: Only entities with ID will be listening for click events. - */ - onBlur: { - /** ID of the entitiy of the event */ - entityId: string - /** ID of the pointer that triggered the event */ - pointerId: number - } - onClick: { - entityId: string - pointerId: number - } - /** - * This event gets triggered when an entity leaves the scene fences. - */ - entityOutOfScene: { - entityId: string - } - /** - * This event gets triggered when an entity enters the scene fences. - */ - entityBackInScene: { - entityId: string - } - uuidEvent: { - uuid: string - payload: any - } - metricsUpdate: { - given: Record - limit: Record - } - limitsExceeded: { - given: Record - limit: Record - } - /** For gizmos */ - gizmoEvent: GizmoDragEndEvent | GizmoSelectedEvent -} - -/** - * Interface for the size containing width and height - * @public - */ -declare interface ISize { - /** - * Width - */ - width: number - /** - * Heighht - */ - height: number -} - -/** - * @public - */ -declare interface ISystem { - active?: boolean - activate?(engine: Engine): void - deactivate?(): void - update?(dt: number): void - onAddEntity?(entity: Entity): void - onRemoveEntity?(entity: Entity): void -} - -/** - * @public - */ -declare class Input { - private static _instance - static readonly instance: Input - readonly state: Readonly - private subscriptions - private internalState - constructor() - /** - * Subscribes to an input event and triggers the provided callback. - * - * Returns a function that can be called to remove the subscription. - * @param eventName - The name of the event (see InputEventKind). - * @param fn - A callback function to be called when the event is triggered. - */ - subscribe(eventName: InputEventKind, fn: (e: PointerEvent) => void): () => void - /** - * Removes an existing input event subscription. - * @param eventName - The name of the event (see InputEventKind). - * @param fn - The callback function used when subscribing to the event. - */ - unsubscribe(eventName: InputEventKind, fn: (e: PointerEvent) => void): void - private getPointerById - private handlePointerUp - private handlePointerDown -} - -declare type InputEventKind = 'BUTTON_A_DOWN' | 'BUTTON_A_UP' - -declare type InputState = Record< - Pointer, - { - BUTTON_A_DOWN: boolean - } -> - -/** - * @public - */ -declare class Material extends ObservableComponent { - /** - * Opacity level between 0 and 1. - * Defaults to 1. - */ - alpha?: number - /** - * AKA Diffuse Color in other nomenclature. - * Defaults to #CCCCCC. - */ - albedoColor?: Color3 - /** - * The color emitted from the material. - * Defaults to black. - */ - emissiveColor?: Color3 - /** - * Specifies the metallic scalar of the metallic/roughness workflow. - * Can also be used to scale the metalness values of the metallic texture. - * Defaults to 0.5. - */ - metallic?: number - /** - * Specifies the roughness scalar of the metallic/roughness workflow. - * Can also be used to scale the roughness values of the metallic texture. - * Defaults to 0.5. - */ - roughness?: number - /** - * AKA Diffuse Color in other nomenclature. - * Defaults to black. - */ - ambientColor?: Color3 - /** - * The color reflected from the material. - * Defaults to white. - */ - reflectionColor?: Color3 - /** - * AKA Specular Color in other nomenclature. - * Defaults to white. - */ - reflectivityColor?: Color3 - /** - * Intensity of the direct lights e.g. the four lights available in scene. - * This impacts both the direct diffuse and specular highlights. - * Defaults to 1. - */ - directIntensity?: number - /** - * AKA Glossiness in other nomenclature. - * Defaults to 1. - */ - microSurface?: number - /** - * Intensity of the emissive part of the material. - * This helps controlling the emissive effect without modifying the emissive color. - * Defaults to 1. - */ - emissiveIntensity?: number - /** - * Intensity of the environment e.g. how much the environment will light the object - * either through harmonics for rough material or through the refelction for shiny ones. - * Defaults to 1. - */ - environmentIntensity?: number - /** - * This is a special control allowing the reduction of the specular highlights coming from the - * four lights of the scene. Those highlights may not be needed in full environment lighting. - * Defaults to 1. - */ - specularIntensity?: number - /** - * Texture applied as material. - */ - albedoTexture?: string - /** - * Texture applied as opacity. Default: the same texture used in albedoTexture. - */ - alphaTexture?: string - /** - * Emissive texture. - */ - emissiveTexture?: string - /** - * Stores surface normal data used to displace a mesh in a texture. - */ - bumpTexture?: string - /** - * Stores the refracted light information in a texture. - */ - refractionTexture?: string - /** - * If sets to true, disables all the lights affecting the material. - * Defaults to false. - */ - disableLighting?: boolean - /** - * Sets the transparency mode of the material. - * Defauts to 0. - * - * | Value | Type | - * | ----- | ----------------------------------- | - * | 0 | OPAQUE (default) | - * | 1 | ALPHATEST | - * | 2 | ALPHABLEND | - * | 3 | ALPHATESTANDBLEND | - */ - transparencyMode?: number - /** - * Does the albedo texture has alpha? - * Defaults to false. - */ - hasAlpha?: boolean -} - -/** - * Class used to store matrix data (4x4) - * @public - */ -declare class Matrix { - /** - * Gets the internal data of the matrix - */ - readonly m: Readonly - /** - * Gets an identity matrix that must not be updated - */ - static readonly IdentityReadOnly: Readonly - private static _updateFlagSeed - private static _identityReadOnly - /** - * Gets the update flag of the matrix which is an unique number for the matrix. - * It will be incremented every time the matrix data change. - * You can use it to speed the comparison between two versions of the same matrix. - */ - updateFlag: number - private _isIdentity - private _isIdentityDirty - private _isIdentity3x2 - private _isIdentity3x2Dirty - private readonly _m - /** - * Creates an empty matrix (filled with zeros) - */ - constructor() - /** - * Creates a matrix from an array - * @param array - defines the source array - * @param offset - defines an offset in the source array - * @returns a new Matrix set from the starting index of the given array - */ - static FromArray(array: ArrayLike, offset?: number): Matrix - /** - * Copy the content of an array into a given matrix - * @param array - defines the source array - * @param offset - defines an offset in the source array - * @param result - defines the target matrix - */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void - /** - * Stores an array into a matrix after having multiplied each component by a given factor - * @param array - defines the source array - * @param offset - defines the offset in the source array - * @param scale - defines the scaling factor - * @param result - defines the target matrix - */ - static FromFloatArrayToRefScaled(array: FloatArray, offset: number, scale: number, result: Matrix): void - /** - * Stores a list of values (16) inside a given matrix - * @param initialM11 - defines 1st value of 1st row - * @param initialM12 - defines 2nd value of 1st row - * @param initialM13 - defines 3rd value of 1st row - * @param initialM14 - defines 4th value of 1st row - * @param initialM21 - defines 1st value of 2nd row - * @param initialM22 - defines 2nd value of 2nd row - * @param initialM23 - defines 3rd value of 2nd row - * @param initialM24 - defines 4th value of 2nd row - * @param initialM31 - defines 1st value of 3rd row - * @param initialM32 - defines 2nd value of 3rd row - * @param initialM33 - defines 3rd value of 3rd row - * @param initialM34 - defines 4th value of 3rd row - * @param initialM41 - defines 1st value of 4th row - * @param initialM42 - defines 2nd value of 4th row - * @param initialM43 - defines 3rd value of 4th row - * @param initialM44 - defines 4th value of 4th row - * @param result - defines the target matrix - */ - static FromValuesToRef( - initialM11: number, - initialM12: number, - initialM13: number, - initialM14: number, - initialM21: number, - initialM22: number, - initialM23: number, - initialM24: number, - initialM31: number, - initialM32: number, - initialM33: number, - initialM34: number, - initialM41: number, - initialM42: number, - initialM43: number, - initialM44: number, - result: Matrix - ): void - /** - * Creates new matrix from a list of values (16) - * @param initialM11 - defines 1st value of 1st row - * @param initialM12 - defines 2nd value of 1st row - * @param initialM13 - defines 3rd value of 1st row - * @param initialM14 - defines 4th value of 1st row - * @param initialM21 - defines 1st value of 2nd row - * @param initialM22 - defines 2nd value of 2nd row - * @param initialM23 - defines 3rd value of 2nd row - * @param initialM24 - defines 4th value of 2nd row - * @param initialM31 - defines 1st value of 3rd row - * @param initialM32 - defines 2nd value of 3rd row - * @param initialM33 - defines 3rd value of 3rd row - * @param initialM34 - defines 4th value of 3rd row - * @param initialM41 - defines 1st value of 4th row - * @param initialM42 - defines 2nd value of 4th row - * @param initialM43 - defines 3rd value of 4th row - * @param initialM44 - defines 4th value of 4th row - * @returns the new matrix - */ - static FromValues( - initialM11: number, - initialM12: number, - initialM13: number, - initialM14: number, - initialM21: number, - initialM22: number, - initialM23: number, - initialM24: number, - initialM31: number, - initialM32: number, - initialM33: number, - initialM34: number, - initialM41: number, - initialM42: number, - initialM43: number, - initialM44: number - ): Matrix - /** - * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3) - * @param scale - defines the scale vector3 - * @param rotation - defines the rotation quaternion - * @param translation - defines the translation vector3 - * @returns a new matrix - */ - static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix - /** - * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3) - * @param scale - defines the scale vector3 - * @param rotation - defines the rotation quaternion - * @param translation - defines the translation vector3 - * @param result - defines the target matrix - */ - static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void - /** - * Creates a new identity matrix - * @returns a new identity matrix - */ - static Identity(): Matrix - /** - * Creates a new identity matrix and stores the result in a given matrix - * @param result - defines the target matrix - */ - static IdentityToRef(result: Matrix): void - /** - * Creates a new zero matrix - * @returns a new zero matrix - */ - static Zero(): Matrix - /** - * Creates a new rotation matrix for "angle" radians around the X axis - * @param angle - defines the angle (in radians) to use - * @returns the new matrix - */ - static RotationX(angle: number): Matrix - /** - * Creates a new matrix as the invert of a given matrix - * @param source - defines the source matrix - * @returns the new matrix - */ - static Invert(source: Matrix): Matrix - /** - * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix - * @param angle - defines the angle (in radians) to use - * @param result - defines the target matrix - */ - static RotationXToRef(angle: number, result: Matrix): void - /** - * Creates a new rotation matrix for "angle" radians around the Y axis - * @param angle - defines the angle (in radians) to use - * @returns the new matrix - */ - static RotationY(angle: number): Matrix - /** - * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix - * @param angle - defines the angle (in radians) to use - * @param result - defines the target matrix - */ - static RotationYToRef(angle: number, result: Matrix): void - /** - * Creates a new rotation matrix for "angle" radians around the Z axis - * @param angle - defines the angle (in radians) to use - * @returns the new matrix - */ - static RotationZ(angle: number): Matrix - /** - * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix - * @param angle - defines the angle (in radians) to use - * @param result - defines the target matrix - */ - static RotationZToRef(angle: number, result: Matrix): void - /** - * Creates a new rotation matrix for "angle" radians around the given axis - * @param axis - defines the axis to use - * @param angle - defines the angle (in radians) to use - * @returns the new matrix - */ - static RotationAxis(axis: Vector3, angle: number): Matrix - /** - * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix - * @param axis - defines the axis to use - * @param angle - defines the angle (in radians) to use - * @param result - defines the target matrix - */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void - /** - * Creates a rotation matrix - * @param yaw - defines the yaw angle in radians (Y axis) - * @param pitch - defines the pitch angle in radians (X axis) - * @param roll - defines the roll angle in radians (X axis) - * @returns the new rotation matrix - */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix - /** - * Creates a rotation matrix and stores it in a given matrix - * @param yaw - defines the yaw angle in radians (Y axis) - * @param pitch - defines the pitch angle in radians (X axis) - * @param roll - defines the roll angle in radians (X axis) - * @param result - defines the target matrix - */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void - /** - * Creates a scaling matrix - * @param x - defines the scale factor on X axis - * @param y - defines the scale factor on Y axis - * @param z - defines the scale factor on Z axis - * @returns the new matrix - */ - static Scaling(x: number, y: number, z: number): Matrix - /** - * Creates a scaling matrix and stores it in a given matrix - * @param x - defines the scale factor on X axis - * @param y - defines the scale factor on Y axis - * @param z - defines the scale factor on Z axis - * @param result - defines the target matrix - */ - static ScalingToRef(x: number, y: number, z: number, result: Matrix): void - /** - * Creates a translation matrix - * @param x - defines the translation on X axis - * @param y - defines the translation on Y axis - * @param z - defines the translationon Z axis - * @returns the new matrix - */ - static Translation(x: number, y: number, z: number): Matrix - /** - * Creates a translation matrix and stores it in a given matrix - * @param x - defines the translation on X axis - * @param y - defines the translation on Y axis - * @param z - defines the translationon Z axis - * @param result - defines the target matrix - */ - static TranslationToRef(x: number, y: number, z: number, result: Matrix): void - /** - * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue". - * @param startValue - defines the start value - * @param endValue - defines the end value - * @param gradient - defines the gradient factor - * @returns the new matrix - */ - static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix - /** - * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue". - * @param startValue - defines the start value - * @param endValue - defines the end value - * @param gradient - defines the gradient factor - * @param result - defines the Matrix object where to store data - */ - static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void - /** - * Builds a new matrix whose values are computed by: - * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices - * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end - * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices - * @param startValue - defines the first matrix - * @param endValue - defines the second matrix - * @param gradient - defines the gradient between the two matrices - * @returns the new matrix - */ - static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix - /** - * Update a matrix to values which are computed by: - * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices - * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end - * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices - * @param startValue - defines the first matrix - * @param endValue - defines the second matrix - * @param gradient - defines the gradient between the two matrices - * @param result - defines the target matrix - */ - static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void - /** - * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up" - * This function works in left handed mode - * @param eye - defines the final position of the entity - * @param target - defines where the entity should look at - * @param up - defines the up vector for the entity - * @returns the new matrix - */ - static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix - /** - * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up". - * This function works in left handed mode - * @param eye - defines the final position of the entity - * @param target - defines where the entity should look at - * @param up - defines the up vector for the entity - * @param result - defines the target matrix - */ - static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void - /** - * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up" - * This function works in right handed mode - * @param eye - defines the final position of the entity - * @param target - defines where the entity should look at - * @param up - defines the up vector for the entity - * @returns the new matrix - */ - static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix - /** - * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up". - * This function works in right handed mode - * @param eye - defines the final position of the entity - * @param target - defines where the entity should look at - * @param up - defines the up vector for the entity - * @param result - defines the target matrix - */ - static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void - /** - * Create a left-handed orthographic projection matrix - * @param width - defines the viewport width - * @param height - defines the viewport height - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @returns a new matrix as a left-handed orthographic projection matrix - */ - static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix - /** - * Store a left-handed orthographic projection to a given matrix - * @param width - defines the viewport width - * @param height - defines the viewport height - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @param result - defines the target matrix - */ - static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void - /** - * Create a left-handed orthographic projection matrix - * @param left - defines the viewport left coordinate - * @param right - defines the viewport right coordinate - * @param bottom - defines the viewport bottom coordinate - * @param top - defines the viewport top coordinate - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @returns a new matrix as a left-handed orthographic projection matrix - */ - static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix - /** - * Stores a left-handed orthographic projection into a given matrix - * @param left - defines the viewport left coordinate - * @param right - defines the viewport right coordinate - * @param bottom - defines the viewport bottom coordinate - * @param top - defines the viewport top coordinate - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @param result - defines the target matrix - */ - static OrthoOffCenterLHToRef( - left: number, - right: number, - bottom: number, - top: number, - znear: number, - zfar: number, - result: Matrix - ): void - /** - * Creates a right-handed orthographic projection matrix - * @param left - defines the viewport left coordinate - * @param right - defines the viewport right coordinate - * @param bottom - defines the viewport bottom coordinate - * @param top - defines the viewport top coordinate - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @returns a new matrix as a right-handed orthographic projection matrix - */ - static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix - /** - * Stores a right-handed orthographic projection into a given matrix - * @param left - defines the viewport left coordinate - * @param right - defines the viewport right coordinate - * @param bottom - defines the viewport bottom coordinate - * @param top - defines the viewport top coordinate - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @param result - defines the target matrix - */ - static OrthoOffCenterRHToRef( - left: number, - right: number, - bottom: number, - top: number, - znear: number, - zfar: number, - result: Matrix - ): void - /** - * Creates a left-handed perspective projection matrix - * @param width - defines the viewport width - * @param height - defines the viewport height - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @returns a new matrix as a left-handed perspective projection matrix - */ - static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix - /** - * Creates a left-handed perspective projection matrix - * @param fov - defines the horizontal field of view - * @param aspect - defines the aspect ratio - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @returns a new matrix as a left-handed perspective projection matrix - */ - static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix - /** - * Stores a left-handed perspective projection into a given matrix - * @param fov - defines the horizontal field of view - * @param aspect - defines the aspect ratio - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @param result - defines the target matrix - * @param isVerticalFovFixed - defines it the fov is vertically fixed (default) or horizontally - */ - static PerspectiveFovLHToRef( - fov: number, - aspect: number, - znear: number, - zfar: number, - result: Matrix, - isVerticalFovFixed?: boolean - ): void - /** - * Creates a right-handed perspective projection matrix - * @param fov - defines the horizontal field of view - * @param aspect - defines the aspect ratio - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @returns a new matrix as a right-handed perspective projection matrix - */ - static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix - /** - * Stores a right-handed perspective projection into a given matrix - * @param fov - defines the horizontal field of view - * @param aspect - defines the aspect ratio - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @param result - defines the target matrix - * @param isVerticalFovFixed - defines it the fov is vertically fixed (default) or horizontally - */ - static PerspectiveFovRHToRef( - fov: number, - aspect: number, - znear: number, - zfar: number, - result: Matrix, - isVerticalFovFixed?: boolean - ): void - /** - * Stores a perspective projection for WebVR info a given matrix - * @param fov - defines the field of view - * @param znear - defines the near clip plane - * @param zfar - defines the far clip plane - * @param result - defines the target matrix - * @param rightHanded - defines if the matrix must be in right-handed mode (false by default) - */ - static PerspectiveFovWebVRToRef( - fov: { - upDegrees: number - downDegrees: number - leftDegrees: number - rightDegrees: number - }, - znear: number, - zfar: number, - result: Matrix, - rightHanded?: boolean - ): void - /** - * Extracts a 2x2 matrix from a given matrix and store the result in a FloatArray - * @param matrix - defines the matrix to use - * @returns a new FloatArray array with 4 elements : the 2x2 matrix extracted from the given matrix - */ - static GetAsMatrix2x2(matrix: Matrix): FloatArray - /** - * Extracts a 3x3 matrix from a given matrix and store the result in a FloatArray - * @param matrix - defines the matrix to use - * @returns a new FloatArray array with 9 elements : the 3x3 matrix extracted from the given matrix - */ - static GetAsMatrix3x3(matrix: Matrix): FloatArray - /** - * Compute the transpose of a given matrix - * @param matrix - defines the matrix to transpose - * @returns the new matrix - */ - static Transpose(matrix: Matrix): Matrix - /** - * Compute the transpose of a matrix and store it in a target matrix - * @param matrix - defines the matrix to transpose - * @param result - defines the target matrix - */ - static TransposeToRef(matrix: Matrix, result: Matrix): void - /** - * Computes a reflection matrix from a plane - * @param plane - defines the reflection plane - * @returns a new matrix - */ - static Reflection(plane: Plane): Matrix - /** - * Computes a reflection matrix from a plane - * @param plane - defines the reflection plane - * @param result - defines the target matrix - */ - static ReflectionToRef(plane: Plane, result: Matrix): void - /** - * Sets the given matrix as a rotation matrix composed from the 3 left handed axes - * @param xaxis - defines the value of the 1st axis - * @param yaxis - defines the value of the 2nd axis - * @param zaxis - defines the value of the 3rd axis - * @param result - defines the target matrix - */ - static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void - /** - * Creates a rotation matrix from a quaternion and stores it in a target matrix - * @param quat - defines the quaternion to use - * @param result - defines the target matrix - */ - static FromQuaternionToRef(quat: Quaternion, result: Matrix): void - /** - * Check if the current matrix is identity - * @returns true is the matrix is the identity matrix - */ - isIdentity(): boolean - /** - * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4) - * @returns true is the matrix is the identity matrix - */ - isIdentityAs3x2(): boolean - /** - * Gets the determinant of the matrix - * @returns the matrix determinant - */ - determinant(): number - /** - * Returns the matrix as a FloatArray - * @returns the matrix underlying array - */ - toArray(): Readonly - /** - * Returns the matrix as a FloatArray - * @returns the matrix underlying array. - */ - asArray(): Readonly - /** - * Inverts the current matrix in place - * @returns the current inverted matrix - */ - invert(): Matrix - /** - * Sets all the matrix elements to zero - * @returns the current matrix - */ - reset(): Matrix - /** - * Adds the current matrix with a second one - * @param other - defines the matrix to add - * @returns a new matrix as the addition of the current matrix and the given one - */ - add(other: Matrix): Matrix - /** - * Sets the given matrix "result" to the addition of the current matrix and the given one - * @param other - defines the matrix to add - * @param result - defines the target matrix - * @returns the current matrix - */ - addToRef(other: Matrix, result: Matrix): Matrix - /** - * Adds in place the given matrix to the current matrix - * @param other - defines the second operand - * @returns the current updated matrix - */ - addToSelf(other: Matrix): Matrix - /** - * Sets the given matrix to the current inverted Matrix - * @param other - defines the target matrix - * @returns the unmodified current matrix - */ - invertToRef(other: Matrix): Matrix - /** - * add a value at the specified position in the current Matrix - * @param index - the index of the value within the matrix. between 0 and 15. - * @param value - the value to be added - * @returns the current updated matrix - */ - addAtIndex(index: number, value: number): Matrix - /** - * mutiply the specified position in the current Matrix by a value - * @param index - the index of the value within the matrix. between 0 and 15. - * @param value - the value to be added - * @returns the current updated matrix - */ - multiplyAtIndex(index: number, value: number): Matrix - /** - * Inserts the translation vector (using 3 floats) in the current matrix - * @param x - defines the 1st component of the translation - * @param y - defines the 2nd component of the translation - * @param z - defines the 3rd component of the translation - * @returns the current updated matrix - */ - setTranslationFromFloats(x: number, y: number, z: number): Matrix - /** - * Inserts the translation vector in the current matrix - * @param vector3 - defines the translation to insert - * @returns the current updated matrix - */ - setTranslation(vector3: Vector3): Matrix - /** - * Gets the translation value of the current matrix - * @returns a new Vector3 as the extracted translation from the matrix - */ - getTranslation(): Vector3 - /** - * Fill a Vector3 with the extracted translation from the matrix - * @param result - defines the Vector3 where to store the translation - * @returns the current matrix - */ - getTranslationToRef(result: Vector3): Matrix - /** - * Remove rotation and scaling part from the matrix - * @returns the updated matrix - */ - removeRotationAndScaling(): Matrix - /** - * Multiply two matrices - * @param other - defines the second operand - * @returns a new matrix set with the multiplication result of the current Matrix and the given one - */ - multiply(other: Readonly): Matrix - /** - * Copy the current matrix from the given one - * @param other - defines the source matrix - * @returns the current updated matrix - */ - copyFrom(other: Readonly): Matrix - /** - * Populates the given array from the starting index with the current matrix values - * @param array - defines the target array - * @param offset - defines the offset in the target array where to start storing values - * @returns the current matrix - */ - copyToArray(array: FloatArray, offset?: number): Matrix - /** - * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one - * @param other - defines the second operand - * @param result - defines the matrix where to store the multiplication - * @returns the current matrix - */ - multiplyToRef(other: Readonly, result: Matrix): Matrix - /** - * Sets the FloatArray "result" from the given index "offset" with the multiplication of the current matrix and the given one - * @param other - defines the second operand - * @param result - defines the array where to store the multiplication - * @param offset - defines the offset in the target array where to start storing values - * @returns the current matrix - */ - multiplyToArray(other: Readonly, result: FloatArray, offset: number): Matrix - /** - * Check equality between this matrix and a second one - * @param value - defines the second matrix to compare - * @returns true is the current matrix and the given one values are strictly equal - */ - equals(value: Matrix): boolean - /** - * Clone the current matrix - * @returns a new matrix from the current matrix - */ - clone(): Matrix - /** - * Returns the name of the current matrix class - * @returns the string "Matrix" - */ - getClassName(): string - /** - * Gets the hash code of the current matrix - * @returns the hash code - */ - getHashCode(): number - /** - * Decomposes the current Matrix into a translation, rotation and scaling components - * @param scale - defines the scale vector3 given as a reference to update - * @param rotation - defines the rotation quaternion given as a reference to update - * @param translation - defines the translation vector3 given as a reference to update - * @returns true if operation was successful - */ - decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean - /** - * Gets specific row of the matrix - * @param index - defines the number of the row to get - * @returns the index-th row of the current matrix as a new Vector4 - */ - getRow(index: number): Nullable - /** - * Sets the index-th row of the current matrix to the vector4 values - * @param index - defines the number of the row to set - * @param row - defines the target vector4 - * @returns the updated current matrix - */ - setRow(index: number, row: Vector4): Matrix - /** - * Compute the transpose of the matrix - * @returns the new transposed matrix - */ - transpose(): Matrix - /** - * Compute the transpose of the matrix and store it in a given matrix - * @param result - defines the target matrix - * @returns the current matrix - */ - transposeToRef(result: Matrix): Matrix - /** - * Sets the index-th row of the current matrix with the given 4 x float values - * @param index - defines the row index - * @param x - defines the x component to set - * @param y - defines the y component to set - * @param z - defines the z component to set - * @param w - defines the w component to set - * @returns the updated current matrix - */ - setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix - /** - * Compute a new matrix set with the current matrix values multiplied by scale (float) - * @param scale - defines the scale factor - * @returns a new matrix - */ - scale(scale: number): Matrix - /** - * Scale the current matrix values by a factor to a given result matrix - * @param scale - defines the scale factor - * @param result - defines the matrix to store the result - * @returns the current matrix - */ - scaleToRef(scale: number, result: Matrix): Matrix - /** - * Scale the current matrix values by a factor and add the result to a given matrix - * @param scale - defines the scale factor - * @param result - defines the Matrix to store the result - * @returns the current matrix - */ - scaleAndAddToRef(scale: number, result: Matrix): Matrix - /** - * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column). - * @param ref - matrix to store the result - */ - toNormalMatrix(ref: Matrix): void - /** - * Gets only rotation part of the current matrix - * @returns a new matrix sets to the extracted rotation matrix from the current one - */ - getRotationMatrix(): Matrix - /** - * Extracts the rotation matrix from the current one and sets it as the given "result" - * @param result - defines the target matrix to store data to - * @returns the current matrix - */ - getRotationMatrixToRef(result: Matrix): Matrix - /** - * Toggles model matrix from being right handed to left handed in place and vice versa - */ - toggleModelMatrixHandInPlace(): void - /** - * Toggles projection matrix from being right handed to left handed in place and vice versa - */ - toggleProjectionMatrixHandInPlace(): void -} - -declare type Nullable = T | null - -/** - * @public - */ -declare class OBJShape extends Shape { - readonly src: string - constructor(src: string) -} - -/** - * @public - */ -declare class ObservableComponent { - dirty: boolean - data: any - private subscriptions - static field(target: ObservableComponent, propertyKey: string): void - static readonly(target: ObservableComponent, propertyKey: string): void - onChange(fn: ObservableComponentSubscription): void - toJSON(): any -} - -declare type ObservableComponentSubscription = (key: string, newVal: any, oldVal: any) => void - -/** - * @public - */ -declare class OnBlur extends OnUUIDEvent<'onBlur'> { - readonly type: string -} - -/** - * @public - */ -declare class OnChanged extends OnUUIDEvent<'onChange'> { - readonly type: string -} - -/** - * @public - */ -declare class OnClick extends OnUUIDEvent<'onClick'> { - readonly type: string -} - -/** - * @public - */ -declare class OnFocus extends OnUUIDEvent<'onFocus'> { - readonly type: string -} - -/** - * This event is triggered after the user finalizes dragging a gizmo. - * @beta - */ -declare class OnGizmoEvent extends OnUUIDEvent<'gizmoEvent'> { - readonly type: string -} - -/** - * @public - */ -declare class OnUUIDEvent extends ObservableComponent { - readonly type: string | undefined - readonly uuid: string - callback: (event: any) => void - constructor(callback: (event: IEvents[T]) => void) - toJSON(): { - uuid: string - type: string | undefined - } -} - -/** - * Defines potential orientation for back face culling - * @public - */ -declare enum Orientation { - /** - * Clockwise - */ - CW = 0, - /** Counter clockwise */ - CCW = 1 -} - -/** - * @public - */ -declare class ParentChanged { - entity: Entity - parent: Entity - constructor(entity: Entity, parent: Entity) -} - -/** - * Represents a 2D path made up of multiple 2D points - * @public - */ -declare class Path2 { - /** - * If the path start and end point are the same - */ - closed: boolean - private _points - private _length - /** - * Creates a Path2 object from the starting 2D coordinates x and y. - * @param x - the starting points x value - * @param y - the starting points y value - */ - constructor(x: number, y: number) - /** - * Creates a new path starting from an x and y position - * @param x - starting x value - * @param y - starting y value - * @returns a new Path2 starting at the coordinates (x, y). - */ - static StartingAt(x: number, y: number): Path2 - /** - * Adds a new segment until the given coordinates (x, y) to the current Path2. - * @param x - the added points x value - * @param y - the added points y value - * @returns the updated Path2. - */ - addLineTo(x: number, y: number): Path2 - /** - * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. - * @param midX - middle point x value - * @param midY - middle point y value - * @param endX - end point x value - * @param endY - end point y value - * @param numberOfSegments - (default: 36) - * @returns the updated Path2. - */ - addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2 - /** - * Closes the Path2. - * @returns the Path2. - */ - close(): Path2 - /** - * Gets the sum of the distance between each sequential point in the path - * @returns the Path2 total length (float). - */ - length(): number - /** - * Gets the points which construct the path - * @returns the Path2 internal array of points. - */ - getPoints(): Vector2[] - /** - * Retreives the point at the distance aways from the starting point - * @param normalizedLengthPosition - the length along the path to retreive the point from - * @returns a new Vector2 located at a percentage of the Path2 total length on this path. - */ - getPointAtLengthPosition(normalizedLengthPosition: number): Vector2 -} - -/** - * Represents a 3D path made up of multiple 3D points - * @public - */ -declare class Path3D { - /** - * an array of Vector3, the curve axis of the Path3D - */ - path: Vector3[] - private _curve - private _distances - private _tangents - private _normals - private _binormals - private _raw - /** - * new Path3D(path, normal, raw) - * Creates a Path3D. A Path3D is a logical math object, so not a mesh. - * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D - * @param path - an array of Vector3, the curve axis of the Path3D - * @param normal - (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. - * @param raw - (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. - */ - constructor( - /** - * an array of Vector3, the curve axis of the Path3D - */ - path: Vector3[], - firstNormal?: Nullable, - raw?: boolean - ) - /** - * Returns the Path3D array of successive Vector3 designing its curve. - * @returns the Path3D array of successive Vector3 designing its curve. - */ - getCurve(): Vector3[] - /** - * Returns an array populated with tangent vectors on each Path3D curve point. - * @returns an array populated with tangent vectors on each Path3D curve point. - */ - getTangents(): Vector3[] - /** - * Returns an array populated with normal vectors on each Path3D curve point. - * @returns an array populated with normal vectors on each Path3D curve point. - */ - getNormals(): Vector3[] - /** - * Returns an array populated with binormal vectors on each Path3D curve point. - * @returns an array populated with binormal vectors on each Path3D curve point. - */ - getBinormals(): Vector3[] - /** - * Returns an array populated with distances (float) of the i-th point from the first curve point. - * @returns an array populated with distances (float) of the i-th point from the first curve point. - */ - getDistances(): number[] - /** - * Forces the Path3D tangent, normal, binormal and distance recomputation. - * @param path - path which all values are copied into the curves points - * @param firstNormal - which should be projected onto the curve - * @returns the same object updated. - */ - update(path: Vector3[], firstNormal?: Nullable): Path3D - private _compute - private _getFirstNonNullVector - private _getLastNonNullVector - private _normalVector -} - -/** - * Represens a plane by the equation ax + by + cz + d = 0 - * @public - */ -declare class Plane { - /** - * Normal of the plane (a,b,c) - */ - normal: Vector3 - /** - * d component of the plane - */ - d: number - /** - * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0 - * @param a - a component of the plane - * @param b - b component of the plane - * @param c - c component of the plane - * @param d - d component of the plane - */ - constructor(a: number, b: number, c: number, d: number) - /** - * Creates a plane from an array - * @param array - the array to create a plane from - * @returns a new Plane from the given array. - */ - static FromArray(array: ArrayLike): Plane - /** - * Creates a plane from three points - * @param point1 - point used to create the plane - * @param point2 - point used to create the plane - * @param point3 - point used to create the plane - * @returns a new Plane defined by the three given points. - */ - static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane - /** - * Creates a plane from an origin point and a normal - * @param origin - origin of the plane to be constructed - * @param normal - normal of the plane to be constructed - * @returns a new Plane the normal vector to this plane at the given origin point. - * Note : the vector "normal" is updated because normalized. - */ - static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane - /** - * Calculates the distance from a plane and a point - * @param origin - origin of the plane to be constructed - * @param normal - normal of the plane to be constructed - * @param point - point to calculate distance to - * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point. - */ - static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number - /** - * @returns the plane coordinates as a new array of 4 elements [a, b, c, d]. - */ - asArray(): number[] - /** - * @returns a new plane copied from the current Plane. - */ - clone(): Plane - /** - * @returns the string "Plane". - */ - getClassName(): string - /** - * @returns the Plane hash code. - */ - getHashCode(): number - /** - * Normalize the current Plane in place. - * @returns the updated Plane. - */ - normalize(): Plane - /** - * Applies a transformation the plane and returns the result - * @param transformation - the transformation matrix to be applied to the plane - * @returns a new Plane as the result of the transformation of the current Plane by the given matrix. - */ - transform(transformation: Matrix): Plane - /** - * Calcualtte the dot product between the point and the plane normal - * @param point - point to calculate the dot product with - * @returns the dot product (float) of the point coordinates and the plane normal. - */ - dotCoordinate(point: Vector3): number - /** - * Updates the current Plane from the plane defined by the three given points. - * @param point1 - one of the points used to contruct the plane - * @param point2 - one of the points used to contruct the plane - * @param point3 - one of the points used to contruct the plane - * @returns the updated Plane. - */ - copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane - /** - * Checks if the plane is facing a given direction - * @param direction - the direction to check if the plane is facing - * @param epsilon - value the dot product is compared against (returns true if dot <= epsilon) - * @returns True is the vector "direction" is the same side than the plane normal. - */ - isFrontFacingTo(direction: Vector3, epsilon: number): boolean - /** - * Calculates the distance to a point - * @param point - point to calculate distance to - * @returns the signed distance (float) from the given point to the Plane. - */ - signedDistanceTo(point: Vector3): number -} - -/** - * @public - */ -declare class PlaneShape extends Shape { - /** - * Sets the horizontal length of the plane. Defaults to 1. - */ - width: number - /** - * Sets the vertical length of the plane. Defaults to 1. - */ - height: number - /** - * Sets the UV coordinates for the plane. - * Used to map specific pieces of a Material's texture into the plane's geometry. - */ - uvs: number[] -} - -/** - * @public - */ -declare enum Pointer { - PRIMARY = 'PRIMARY', - SECONDARY = 'SECONDARY' -} - -declare type PointerEvent = { - /** Origin of the ray */ - from: Vector3 - /** Direction vector of the ray (normalized) */ - direction: Vector3 - /** Length of the ray */ - length: number - /** ID of the pointer that triggered the event */ - pointerId: Pointer -} - -declare type PointerEvent_2 = { - /** Origin of the ray */ - from: ReadOnlyVector3 - /** Direction vector of the ray (normalized) */ - direction: ReadOnlyVector3 - /** Length of the ray */ - length: number - /** ID of the pointer that triggered the event */ - pointerId: number -} - -/** - * Class used to store quaternion data - * {@link https://en.wikipedia.org/wiki/Quaternion } - * {@link http://doc.babylonjs.com/features/position,_rotation,_scaling } - * @public - */ -declare class Quaternion { - /** defines the first component (0 by default) */ - x: number - /** defines the second component (0 by default) */ - y: number - /** defines the third component (0 by default) */ - z: number - /** defines the fourth component (1.0 by default) */ - w: number - /** - * Creates a new Quaternion from the given floats - * @param x - defines the first component (0 by default) - * @param y - defines the second component (0 by default) - * @param z - defines the third component (0 by default) - * @param w - defines the fourth component (1.0 by default) - */ - constructor( - /** defines the first component (0 by default) */ - x?: number, - /** defines the second component (0 by default) */ - y?: number, - /** defines the third component (0 by default) */ - z?: number, - /** defines the fourth component (1.0 by default) */ - w?: number - ) - /** - * Creates a new quaternion from a rotation matrix - * @param matrix - defines the source matrix - * @returns a new quaternion created from the given rotation matrix values - */ - static FromRotationMatrix(matrix: Matrix): Quaternion - /** - * Updates the given quaternion with the given rotation matrix values - * @param matrix - defines the source matrix - * @param result - defines the target quaternion - */ - static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void - /** - * Returns the dot product (float) between the quaternions "left" and "right" - * @param left - defines the left operand - * @param right - defines the right operand - * @returns the dot product - */ - static Dot(left: Quaternion, right: Quaternion): number - /** - * Checks if the two quaternions are close to each other - * @param quat0 - defines the first quaternion to check - * @param quat1 - defines the second quaternion to check - * @returns true if the two quaternions are close to each other - */ - static AreClose(quat0: Quaternion, quat1: Quaternion): boolean - /** - * Creates an empty quaternion - * @returns a new quaternion set to (0.0, 0.0, 0.0) - */ - static Zero(): Quaternion - /** - * Inverse a given quaternion - * @param q - defines the source quaternion - * @returns a new quaternion as the inverted current quaternion - */ - static Inverse(q: Quaternion): Quaternion - /** - * Gets a boolean indicating if the given quaternion is identity - * @param quaternion - defines the quaternion to check - * @returns true if the quaternion is identity - */ - static IsIdentity(quaternion: Quaternion): boolean - /** - * Creates a quaternion from a rotation around an axis - * @param axis - defines the axis to use - * @param angle - defines the angle to use (in Euler degrees) - * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float) - */ - static RotationAxis(axis: Vector3, angle: number): Quaternion - /** - * Creates a rotation around an axis and stores it into the given quaternion - * @param axis - defines the axis to use - * @param angle - defines the angle to use (in Euler degrees) - * @param result - defines the target quaternion - * @returns the target quaternion - */ - static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion - /** - * Creates a new quaternion from data stored into an array - * @param array - defines the data source - * @param offset - defines the offset in the source array where the data starts - * @returns a new quaternion - */ - static FromArray(array: ArrayLike, offset?: number): Quaternion - /** - * Creates a new quaternion from a set of euler angles and stores it in the target quaternion - */ - static FromEulerAnglesRef(x: number, y: number, z: number, result: Quaternion): void - /** - * Creates a new quaternion from the given Euler float angles (y, x, z) - * @param yaw - defines the rotation around Y axis - * @param pitch - defines the rotation around X axis - * @param roll - defines the rotation around Z axis - * @returns the new quaternion - */ - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion - /** - * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion - * @param yaw - defines the rotation around Y axis - * @param pitch - defines the rotation around X axis - * @param roll - defines the rotation around Z axis - * @param result - defines the target quaternion - */ - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void - /** - * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation - * @param alpha - defines the rotation around first axis - * @param beta - defines the rotation around second axis - * @param gamma - defines the rotation around third axis - * @returns the new quaternion - */ - static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion - /** - * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion - * @param alpha - defines the rotation around first axis - * @param beta - defines the rotation around second axis - * @param gamma - defines the rotation around third axis - * @param result - defines the target quaternion - */ - static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void - /** - * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) - * @param axis1 - defines the first axis - * @param axis2 - defines the second axis - * @param axis3 - defines the third axis - * @returns the new quaternion - */ - static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion - /** - * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion - * @param axis1 - defines the first axis - * @param axis2 - defines the second axis - * @param axis3 - defines the third axis - * @param ref - defines the target quaternion - */ - static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void - /** - * Interpolates between two quaternions - * @param left - defines first quaternion - * @param right - defines second quaternion - * @param amount - defines the gradient to use - * @returns the new interpolated quaternion - */ - static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion - /** - * Interpolates between two quaternions and stores it into a target quaternion - * @param left - defines first quaternion - * @param right - defines second quaternion - * @param amount - defines the gradient to use - * @param result - defines the target quaternion - */ - static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void - /** - * Interpolate between two quaternions using Hermite interpolation - * @param value1 - defines first quaternion - * @param tangent1 - defines the incoming tangent - * @param value2 - defines second quaternion - * @param tangent2 - defines the outgoing tangent - * @param amount - defines the target quaternion - * @returns the new interpolated quaternion - */ - static Hermite( - value1: Quaternion, - tangent1: Quaternion, - value2: Quaternion, - tangent2: Quaternion, - amount: number - ): Quaternion - /** - * Creates an identity quaternion - * @returns - the identity quaternion - */ - static readonly Identity: Quaternion - /** - * Returns the angle in degrees between two rotations a and b. - * @param quat1 - defines the first quaternion - * @param quat2 - defines the second quaternion - */ - static Angle(quat1: Quaternion, quat2: Quaternion): number - /** - * Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis. - * @param x - the rotation on the x axis in euler degrees - * @param y - the rotation on the y axis in euler degrees - * @param z - the rotation on the z axis in euler degrees - */ - static Euler(x: number, y: number, z: number): Quaternion - /** - * Creates a rotation with the specified forward and upwards directions. - * @param forward - the direction to look in - * @param up - the vector that defines in which direction up is - */ - static LookRotation(forward: Vector3, up?: Vector3): Quaternion - /** - * The from quaternion is rotated towards to by an angular step of maxDegreesDelta. - * @param from - defines the first quaternion - * @param to - defines the second quaternion - * @param maxDegreesDelta - the interval step - */ - static RotateTowards(from: Quaternion, to: Quaternion, maxDegreesDelta: number): Quaternion - /** - * Creates a rotation which rotates from fromDirection to toDirection. - * @param from - defines the first Vector - * @param to - defines the second Vector - */ - static FromToRotation(from: Vector3, to: Vector3): Quaternion - /** - * Converts this quaternion to one with the same orientation but with a magnitude of 1. - */ - readonly normalized: Quaternion - /** - * Creates a rotation which rotates from fromDirection to toDirection. - * @param from - defines the first Vector - * @param to - defines the second Vector - * @param up - defines the direction - */ - setFromToRotation(from: Vector3, to: Vector3, up?: Vector3): void - /** - * Gets the euler angle representation of the rotation. - */ - /** - * Sets the euler angle representation of the rotation. - */ - eulerAngles: Vector3 - /** - * Gets a string representation for the current quaternion - * @returns a string with the Quaternion coordinates - */ - toString(): string - /** - * Gets length of current quaternion - * @returns the quaternion length (float) - */ - readonly length: number - /** - * Gets length of current quaternion - * @returns the quaternion length (float) - */ - readonly lengthSquared: number - /** - * Gets the class name of the quaternion - * @returns the string "Quaternion" - */ - getClassName(): string - /** - * Gets a hash code for this quaternion - * @returns the quaternion hash code - */ - getHashCode(): number - /** - * Copy the quaternion to an array - * @returns a new array populated with 4 elements from the quaternion coordinates - */ - asArray(): number[] - /** - * Check if two quaternions are equals - * @param otherQuaternion - defines the second operand - * @returns true if the current quaternion and the given one coordinates are strictly equals - */ - equals(otherQuaternion: Quaternion): boolean - /** - * Clone the current quaternion - * @returns a new quaternion copied from the current one - */ - clone(): Quaternion - /** - * Copy a quaternion to the current one - * @param other - defines the other quaternion - * @returns the updated current quaternion - */ - copyFrom(other: Quaternion): Quaternion - /** - * Updates the current quaternion with the given float coordinates - * @param x - defines the x coordinate - * @param y - defines the y coordinate - * @param z - defines the z coordinate - * @param w - defines the w coordinate - * @returns the updated current quaternion - */ - copyFromFloats(x: number, y: number, z: number, w: number): Quaternion - /** - * Updates the current quaternion from the given float coordinates - * @param x - defines the x coordinate - * @param y - defines the y coordinate - * @param z - defines the z coordinate - * @param w - defines the w coordinate - * @returns the updated current quaternion - */ - set(x: number, y: number, z: number, w: number): Quaternion - /** - * Updates the current quaternion from the given euler angles - * @returns the updated current quaternion - */ - setEuler(x: number, y: number, z: number): Quaternion - /** - * Subtract two quaternions - * @param other - defines the second operand - * @returns a new quaternion as the subtraction result of the given one from the current one - */ - subtract(other: Quaternion): Quaternion - /** - * Multiplies the current quaternion by a scale factor - * @param value - defines the scale factor - * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale" - */ - scale(value: number): Quaternion - /** - * Scale the current quaternion values by a factor and stores the result to a given quaternion - * @param scale - defines the scale factor - * @param result - defines the Quaternion object where to store the result - * @returns the unmodified current quaternion - */ - scaleToRef(scale: number, result: Quaternion): Quaternion - /** - * Multiplies in place the current quaternion by a scale factor - * @param value - defines the scale factor - * @returns the current modified quaternion - */ - scaleInPlace(value: number): Quaternion - /** - * Scale the current quaternion values by a factor and add the result to a given quaternion - * @param scale - defines the scale factor - * @param result - defines the Quaternion object where to store the result - * @returns the unmodified current quaternion - */ - scaleAndAddToRef(scale: number, result: Quaternion): Quaternion - /** - * Multiplies two quaternions - * @param q1 - defines the second operand - * @returns a new quaternion set as the multiplication result of the current one with the given one "q1" - */ - multiply(q1: Quaternion): Quaternion - /** - * Sets the given "result" as the the multiplication result of the current one with the given one "q1" - * @param q1 - defines the second operand - * @param result - defines the target quaternion - * @returns the current quaternion - */ - multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion - /** - * Updates the current quaternion with the multiplication of itself with the given one "q1" - * @param q1 - defines the second operand - * @returns the currentupdated quaternion - */ - multiplyInPlace(q1: Quaternion): Quaternion - /** - * Conjugates (1-q) the current quaternion and stores the result in the given quaternion - * @param ref - defines the target quaternion - * @returns the current quaternion - */ - conjugateToRef(ref: Quaternion): Quaternion - /** - * Conjugates in place (1-q) the current quaternion - * @returns the current updated quaternion - */ - conjugateInPlace(): Quaternion - /** - * Conjugates in place (1-q) the current quaternion - * @returns a new quaternion - */ - conjugate(): Quaternion - /** - * Normalize in place the current quaternion - * @returns the current updated quaternion - */ - normalize(): Quaternion - angleAxis(degress: number, axis: Vector3): Quaternion - /** - * Updates the given rotation matrix with the current quaternion values - * @param result - defines the target matrix - * @returns the current unchanged quaternion - */ - toRotationMatrix(result: Matrix): Quaternion - /** - * Updates the current quaternion from the given rotation matrix values - * @param matrix - defines the source matrix - * @returns the current updated quaternion - */ - fromRotationMatrix(matrix: Matrix): Quaternion -} - -declare const RAD2DEG: number - -declare type ReadOnlyQuaternion = { - readonly x: number - readonly y: number - readonly z: number - readonly w: number -} - -declare type ReadOnlyVector2 = { - readonly x: number - readonly y: number -} - -declare type ReadOnlyVector3 = { - readonly y: number - readonly x: number - readonly z: number -} - -declare type ReadOnlyVector4 = { - readonly y: number - readonly x: number - readonly z: number - readonly w: number -} - -/** - * Scalar computation library - * @public - */ -declare class Scalar { - /** - * Two pi constants convenient for computation. - */ - static TwoPi: number - /** - * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) - * @param a - number - * @param b - number - * @param epsilon - (default = 1.401298E-45) - * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) - */ - static WithinEpsilon(a: number, b: number, epsilon?: number): boolean - /** - * Returns a string : the upper case translation of the number i to hexadecimal. - * @param i - number - * @returns the upper case translation of the number i to hexadecimal. - */ - static ToHex(i: number): string - /** - * Returns -1 if value is negative and +1 is value is positive. - * @param _value - the value - * @returns the value itself if it's equal to zero. - */ - static Sign(value: number): number - /** - * Returns the value itself if it's between min and max. - * Returns min if the value is lower than min. - * Returns max if the value is greater than max. - * @param value - the value to clmap - * @param min - the min value to clamp to (default: 0) - * @param max - the max value to clamp to (default: 1) - * @returns the clamped value - */ - static Clamp(value: number, min?: number, max?: number): number - /** - * the log2 of value. - * @param value - the value to compute log2 of - * @returns the log2 of value. - */ - static Log2(value: number): number - /** - * Loops the value, so that it is never larger than length and never smaller than 0. - * - * This is similar to the modulo operator but it works with floating point numbers. - * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. - * With t = 5 and length = 2.5, the result would be 0.0. - * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator - * @param value - the value - * @param length - the length - * @returns the looped value - */ - static Repeat(value: number, length: number): number - /** - * Normalize the value between 0.0 and 1.0 using min and max values - * @param value - value to normalize - * @param min - max to normalize between - * @param max - min to normalize between - * @returns the normalized value - */ - static Normalize(value: number, min: number, max: number): number - /** - * Denormalize the value from 0.0 and 1.0 using min and max values - * @param normalized - value to denormalize - * @param min - max to denormalize between - * @param max - min to denormalize between - * @returns the denormalized value - */ - static Denormalize(normalized: number, min: number, max: number): number - /** - * Calculates the shortest difference between two given angles given in degrees. - * @param current - current angle in degrees - * @param target - target angle in degrees - * @returns the delta - */ - static DeltaAngle(current: number, target: number): number - /** - * PingPongs the value t, so that it is never larger than length and never smaller than 0. - * @param tx - value - * @param length - length - * @returns The returned value will move back and forth between 0 and length - */ - static PingPong(tx: number, length: number): number - /** - * Interpolates between min and max with smoothing at the limits. - * - * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up - * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. - * @param from - from - * @param to - to - * @param tx - value - * @returns the smooth stepped value - */ - static SmoothStep(from: number, to: number, tx: number): number - /** - * Moves a value current towards target. - * - * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. - * Negative values of maxDelta pushes the value away from target. - * @param current - current value - * @param target - target value - * @param maxDelta - max distance to move - * @returns resulting value - */ - static MoveTowards(current: number, target: number, maxDelta: number): number - /** - * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. - * - * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta - * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. - * @param current - current value - * @param target - target value - * @param maxDelta - max distance to move - * @returns resulting angle - */ - static MoveTowardsAngle(current: number, target: number, maxDelta: number): number - /** - * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. - * @param start - start value - * @param end - target value - * @param amount - amount to lerp between - * @returns the lerped value - */ - static Lerp(start: number, end: number, amount: number): number - /** - * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. - * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. - * @param start - start value - * @param end - target value - * @param amount - amount to lerp between - * @returns the lerped value - */ - static LerpAngle(start: number, end: number, amount: number): number - /** - * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. - * @param a - start value - * @param b - target value - * @param value - value between a and b - * @returns the inverseLerp value - */ - static InverseLerp(a: number, b: number, value: number): number - /** - * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". - * {@link http://mathworld.wolfram.com/HermitePolynomial.html} - * @param value1 - spline value - * @param tangent1 - spline value - * @param value2 - spline value - * @param tangent2 - spline value - * @param amount - input value - * @returns hermite result - */ - static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number - /** - * Returns a random float number between and min and max values - * @param min - min value of random - * @param max - max value of random - * @returns random value - */ - static RandomRange(min: number, max: number): number - /** - * This function returns percentage of a number in a given range. - * - * RangeToPercent(40,20,60) will return 0.5 (50%) - * RangeToPercent(34,0,100) will return 0.34 (34%) - * @param num - to convert to percentage - * @param min - min range - * @param max - max range - * @returns the percentage - */ - static RangeToPercent(num: number, min: number, max: number): number - /** - * This function returns number that corresponds to the percentage in a given range. - * - * PercentToRange(0.34,0,100) will return 34. - * @param percent - to convert to number - * @param min - min range - * @param max - max range - * @returns the number - */ - static PercentToRange(percent: number, min: number, max: number): number - /** - * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians. - * @param angle - The angle to normalize in radian. - * @returns The converted angle. - */ - static NormalizeRadians(angle: number): number -} - -/** - * @public - */ -declare class Shape extends ObservableComponent { - /** - * Set to true to turn on the collider for the entity. - * @alpha - */ - withCollisions: boolean - /** - * Defines if the entity and its children should be rendered - * @alpha - */ - visible: boolean -} - -/** - * Size containing widht and height - * @public - */ -declare class Size implements ISize { - /** - * The surface of the Size : width * height (float). - */ - readonly surface: number - /** - * Width - */ - width: number - /** - * Height - */ - height: number - /** - * Creates a Size object from the given width and height (floats). - * @param width - width of the new size - * @param height - height of the new size - */ - constructor(width: number, height: number) - /** - * Create a new size of zero - * @returns a new Size set to (0.0, 0.0) - */ - static Zero(): Size - /** - * Creates a new Size set at the linear interpolation "amount" between "start" and "end" - * @param start - starting size to lerp between - * @param end - end size to lerp between - * @param amount - amount to lerp between the start and end values - * @returns a new Size set at the linear interpolation "amount" between "start" and "end" - */ - static Lerp(start: Size, end: Size, amount: number): Size - /** - * Returns a string with the Size width and height - * @returns a string with the Size width and height - */ - toString(): string - /** - * "Size" - * @returns the string "Size" - */ - getClassName(): string - /** - * Returns the Size hash code. - * @returns a hash code for a unique width and height - */ - getHashCode(): number - /** - * Updates the current size from the given one. - * @param src - the given size - */ - copyFrom(src: Size): void - /** - * Updates in place the current Size from the given floats. - * @param width - width of the new size - * @param height - height of the new size - * @returns the updated Size. - */ - copyFromFloats(width: number, height: number): Size - /** - * Updates in place the current Size from the given floats. - * @param width - width to set - * @param height - height to set - * @returns the updated Size. - */ - set(width: number, height: number): Size - /** - * Multiplies the width and height by numbers - * @param w - factor to multiple the width by - * @param h - factor to multiple the height by - * @returns a new Size set with the multiplication result of the current Size and the given floats. - */ - multiplyByFloats(w: number, h: number): Size - /** - * Clones the size - * @returns a new Size copied from the given one. - */ - clone(): Size - /** - * True if the current Size and the given one width and height are strictly equal. - * @param other - the other size to compare against - * @returns True if the current Size and the given one width and height are strictly equal. - */ - equals(other: Size): boolean - /** - * Sums the width and height of two sizes - * @param otherSize - size to add to this size - * @returns a new Size set as the addition result of the current Size and the given one. - */ - add(otherSize: Size): Size - /** - * Subtracts the width and height of two - * @param otherSize - size to subtract to this size - * @returns a new Size set as the subtraction result of the given one from the current Size. - */ - subtract(otherSize: Size): Size -} - -/** - * Defines supported spaces - * @public - */ -declare enum Space { - /** Local (object) space */ - LOCAL = 0, - /** World space */ - WORLD = 1, - /** Bone space */ - BONE = 2 -} - -/** - * @public - */ -declare class SphereShape extends Shape {} - -declare type TaskResult = Promise & { - isComplete: boolean - didFail?: boolean - error?: Error - result?: T -} - -/** - * @public - */ -declare class TextShape extends Shape { - outlineWidth: number - outlineColor: Color3 - color: Color3 - fontFamily: string - fontSize: number - fontWeight: string - opacity: number - value: string - lineSpacing: string - lineCount: number - resizeToFit: boolean - textWrapping: boolean - shadowBlur: number - shadowOffsetX: number - shadowOffsetY: number - shadowColor: Color3 - zIndex: number - hAlign: string - vAlign: string - width: number - height: number - paddingTop: number - paddingRight: number - paddingBottom: number - paddingLeft: number - isPickable: boolean - billboard: boolean - constructor(value?: string) -} - -declare const ToGammaSpace: number - -declare const ToLinearSpace = 2.2 - -declare type TranformConstructorArgs = { - position?: Vector3 - rotation?: Quaternion - scale?: Vector3 -} - -/** - * @public - */ -declare class Transform extends ObservableComponent { - position: Vector3 - rotation: Quaternion - scale: Vector3 - constructor(args?: TranformConstructorArgs) - /** - * @public - * The rotation as Euler angles in degrees. - */ - readonly eulerAngles: Vector3 - /** - * @public - * Rotates the transform so the forward vector points at target's current position. - */ - lookAt(target: Vector3, worldUp?: Vector3): void - /** - * @public - * Applies a rotation of euler angles around the x, y and z axis. - */ - rotate(axis: Vector3, angle: number): void - /** - * @public - * Moves the transform in the direction and distance of translation. - */ - translate(vec: Vector3): void -} - -/** - * @public - */ -declare class UUIDEvent { - uuid: string - payload: T -} - -/** - * @public - */ -declare class UUIDEventSystem implements ISystem { - handlerMap: { - [uuid: string]: OnUUIDEvent - } - activate(engine: Engine): void - deactivate(): void - onAddEntity(entity: Entity): void - onRemoveEntity(entity: Entity): void - private componentAdded - private componentRemoved - private handleEvent -} - -/** - * Class representing a vector containing 2 coordinates - * @public - */ -declare class Vector2 { - /** defines the first coordinate */ - x: number - /** defines the second coordinate */ - y: number - /** - * Creates a new Vector2 from the given x and y coordinates - * @param x - defines the first coordinate - * @param y - defines the second coordinate - */ - constructor( - /** defines the first coordinate */ - x?: number, - /** defines the second coordinate */ - y?: number - ) - /** - * Gets a new Vector2(0, 0) - * @returns a new Vector2 - */ - static Zero(): Vector2 - /** - * Gets a new Vector2(1, 1) - * @returns a new Vector2 - */ - static One(): Vector2 - /** - * Returns a new Vector2 as the result of the addition of the two given vectors. - * @param vector1 - the first vector - * @param vector2 - the second vector - * @returns the resulting vector - */ - static Add(vector1: ReadOnlyVector2, vector2: ReadOnlyVector2): Vector2 - /** - * Gets a new Vector2 set from the given index element of the given array - * @param array - defines the data source - * @param offset - defines the offset in the data source - * @returns a new Vector2 - */ - static FromArray(array: ArrayLike, offset?: number): Vector2 - /** - * Sets "result" from the given index element of the given array - * @param array - defines the data source - * @param offset - defines the offset in the data source - * @param result - defines the target vector - */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void - /** - * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2 - * @param value1 - defines 1st point of control - * @param value2 - defines 2nd point of control - * @param value3 - defines 3rd point of control - * @param value4 - defines 4th point of control - * @param amount - defines the interpolation factor - * @returns a new Vector2 - */ - static CatmullRom( - value1: ReadOnlyVector2, - value2: ReadOnlyVector2, - value3: ReadOnlyVector2, - value4: ReadOnlyVector2, - amount: number - ): Vector2 - /** - * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". - * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. - * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate - * @param value - defines the value to clamp - * @param min - defines the lower limit - * @param max - defines the upper limit - * @returns a new Vector2 - */ - static Clamp(value: ReadOnlyVector2, min: ReadOnlyVector2, max: ReadOnlyVector2): Vector2 - /** - * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2" - * @param value1 - defines the 1st control point - * @param tangent1 - defines the outgoing tangent - * @param value2 - defines the 2nd control point - * @param tangent2 - defines the incoming tangent - * @param amount - defines the interpolation factor - * @returns a new Vector2 - */ - static Hermite( - value1: ReadOnlyVector2, - tangent1: ReadOnlyVector2, - value2: ReadOnlyVector2, - tangent2: ReadOnlyVector2, - amount: number - ): Vector2 - /** - * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". - * @param start - defines the start vector - * @param end - defines the end vector - * @param amount - defines the interpolation factor - * @returns a new Vector2 - */ - static Lerp(start: ReadOnlyVector2, end: ReadOnlyVector2, amount: number): Vector2 - /** - * Gets the dot product of the vector "left" and the vector "right" - * @param left - defines first vector - * @param right - defines second vector - * @returns the dot product (float) - */ - static Dot(left: ReadOnlyVector2, right: ReadOnlyVector2): number - /** - * Returns a new Vector2 equal to the normalized given vector - * @param vector - defines the vector to normalize - * @returns a new Vector2 - */ - static Normalize(vector: ReadOnlyVector2): Vector2 - /** - * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors - * @param left - defines 1st vector - * @param right - defines 2nd vector - * @returns a new Vector2 - */ - static Minimize(left: ReadOnlyVector2, right: ReadOnlyVector2): Vector2 - /** - * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors - * @param left - defines 1st vector - * @param right - defines 2nd vector - * @returns a new Vector2 - */ - static Maximize(left: ReadOnlyVector2, right: ReadOnlyVector2): Vector2 - /** - * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix - * @param vector - defines the vector to transform - * @param transformation - defines the matrix to apply - * @returns a new Vector2 - */ - static Transform(vector: Vector2, transformation: Matrix): Vector2 - /** - * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates - * @param vector - defines the vector to transform - * @param transformation - defines the matrix to apply - * @param result - defines the target vector - */ - static TransformToRef(vector: ReadOnlyVector2, transformation: Matrix, result: Vector2): void - /** - * Determines if a given vector is included in a triangle - * @param p - defines the vector to test - * @param p0 - defines 1st triangle point - * @param p1 - defines 2nd triangle point - * @param p2 - defines 3rd triangle point - * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" - */ - static PointInTriangle(p: ReadOnlyVector2, p0: ReadOnlyVector2, p1: ReadOnlyVector2, p2: ReadOnlyVector2): boolean - /** - * Gets the distance between the vectors "value1" and "value2" - * @param value1 - defines first vector - * @param value2 - defines second vector - * @returns the distance between vectors - */ - static Distance(value1: Vector2, value2: Vector2): number - /** - * Returns the squared distance between the vectors "value1" and "value2" - * @param value1 - defines first vector - * @param value2 - defines second vector - * @returns the squared distance between vectors - */ - static DistanceSquared(value1: ReadOnlyVector2, value2: ReadOnlyVector2): number - /** - * Gets a new Vector2 located at the center of the vectors "value1" and "value2" - * @param value1 - defines first vector - * @param value2 - defines second vector - * @returns a new Vector2 - */ - static Center(value1: ReadOnlyVector2, value2: ReadOnlyVector2): Vector2 - /** - * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". - * @param p - defines the middle point - * @param segA - defines one point of the segment - * @param segB - defines the other point of the segment - * @returns the shortest distance - */ - static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number - /** - * Gets a string with the Vector2 coordinates - * @returns a string with the Vector2 coordinates - */ - toString(): string - /** - * Gets class name - * @returns the string "Vector2" - */ - getClassName(): string - /** - * Gets current vector hash code - * @returns the Vector2 hash code as a number - */ - getHashCode(): number - /** - * Sets the Vector2 coordinates in the given array or FloatArray from the given index. - * @param array - defines the source array - * @param index - defines the offset in source array - * @returns the current Vector2 - */ - toArray(array: FloatArray, index?: number): Vector2 - /** - * Copy the current vector to an array - * @returns a new array with 2 elements: the Vector2 coordinates. - */ - asArray(): number[] - /** - * Sets the Vector2 coordinates with the given Vector2 coordinates - * @param source - defines the source Vector2 - * @returns the current updated Vector2 - */ - copyFrom(source: ReadOnlyVector2): Vector2 - /** - * Sets the Vector2 coordinates with the given floats - * @param x - defines the first coordinate - * @param y - defines the second coordinate - * @returns the current updated Vector2 - */ - copyFromFloats(x: number, y: number): Vector2 - /** - * Sets the Vector2 coordinates with the given floats - * @param x - defines the first coordinate - * @param y - defines the second coordinate - * @returns the current updated Vector2 - */ - set(x: number, y: number): Vector2 - /** - * Add another vector with the current one - * @param otherVector - defines the other vector - * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates - */ - add(otherVector: ReadOnlyVector2): Vector2 - /** - * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates - * @param otherVector - defines the other vector - * @param result - defines the target vector - * @returns the unmodified current Vector2 - */ - addToRef(otherVector: ReadOnlyVector2, result: Vector2): Vector2 - /** - * Set the Vector2 coordinates by adding the given Vector2 coordinates - * @param otherVector - defines the other vector - * @returns the current updated Vector2 - */ - addInPlace(otherVector: ReadOnlyVector2): Vector2 - /** - * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates - * @param otherVector - defines the other vector - * @returns a new Vector2 - */ - addVector3(otherVector: ReadOnlyVector2): Vector2 - /** - * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2 - * @param otherVector - defines the other vector - * @returns a new Vector2 - */ - subtract(otherVector: ReadOnlyVector2): Vector2 - /** - * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates. - * @param otherVector - defines the other vector - * @param result - defines the target vector - * @returns the unmodified current Vector2 - */ - subtractToRef(otherVector: ReadOnlyVector2, result: Vector2): Vector2 - /** - * Sets the current Vector2 coordinates by subtracting from it the given one coordinates - * @param otherVector - defines the other vector - * @returns the current updated Vector2 - */ - subtractInPlace(otherVector: ReadOnlyVector2): Vector2 - /** - * Multiplies in place the current Vector2 coordinates by the given ones - * @param otherVector - defines the other vector - * @returns the current updated Vector2 - */ - multiplyInPlace(otherVector: ReadOnlyVector2): Vector2 - /** - * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates - * @param otherVector - defines the other vector - * @returns a new Vector2 - */ - multiply(otherVector: ReadOnlyVector2): Vector2 - /** - * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates - * @param otherVector - defines the other vector - * @param result - defines the target vector - * @returns the unmodified current Vector2 - */ - multiplyToRef(otherVector: ReadOnlyVector2, result: Vector2): Vector2 - /** - * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats - * @param x - defines the first coordinate - * @param y - defines the second coordinate - * @returns a new Vector2 - */ - multiplyByFloats(x: number, y: number): Vector2 - /** - * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates - * @param otherVector - defines the other vector - * @returns a new Vector2 - */ - divide(otherVector: ReadOnlyVector2): Vector2 - /** - * Sets the "result" coordinates with the Vector2 divided by the given one coordinates - * @param otherVector - defines the other vector - * @param result - defines the target vector - * @returns the unmodified current Vector2 - */ - divideToRef(otherVector: ReadOnlyVector2, result: Vector2): Vector2 - /** - * Divides the current Vector2 coordinates by the given ones - * @param otherVector - defines the other vector - * @returns the current updated Vector2 - */ - divideInPlace(otherVector: ReadOnlyVector2): Vector2 - /** - * Gets a new Vector2 with current Vector2 negated coordinates - * @returns a new Vector2 - */ - negate(): Vector2 - /** - * Multiply the Vector2 coordinates by scale - * @param scale - defines the scaling factor - * @returns the current updated Vector2 - */ - scaleInPlace(scale: number): Vector2 - /** - * Returns a new Vector2 scaled by "scale" from the current Vector2 - * @param scale - defines the scaling factor - * @returns a new Vector2 - */ - scale(scale: number): Vector2 - /** - * Scale the current Vector2 values by a factor to a given Vector2 - * @param scale - defines the scale factor - * @param result - defines the Vector2 object where to store the result - * @returns the unmodified current Vector2 - */ - scaleToRef(scale: number, result: Vector2): Vector2 - /** - * Scale the current Vector2 values by a factor and add the result to a given Vector2 - * @param scale - defines the scale factor - * @param result - defines the Vector2 object where to store the result - * @returns the unmodified current Vector2 - */ - scaleAndAddToRef(scale: number, result: Vector2): Vector2 - /** - * Gets a boolean if two vectors are equals - * @param otherVector - defines the other vector - * @returns true if the given vector coordinates strictly equal the current Vector2 ones - */ - equals(otherVector: ReadOnlyVector2): boolean - /** - * Gets a boolean if two vectors are equals (using an epsilon value) - * @param otherVector - defines the other vector - * @param epsilon - defines the minimal distance to consider equality - * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon. - */ - equalsWithEpsilon(otherVector: ReadOnlyVector2, epsilon?: number): boolean - /** - * Gets a new Vector2 from current Vector2 floored values - * @returns a new Vector2 - */ - floor(): Vector2 - /** - * Gets a new Vector2 from current Vector2 floored values - * @returns a new Vector2 - */ - fract(): Vector2 - /** - * Gets the length of the vector - * @returns the vector length (float) - */ - length(): number - /** - * Gets the vector squared length - * @returns the vector squared length (float) - */ - lengthSquared(): number - /** - * Normalize the vector - * @returns the current updated Vector2 - */ - normalize(): Vector2 - /** - * Gets a new Vector2 copied from the Vector2 - * @returns a new Vector2 - */ - clone(): Vector2 -} - -/** - * Classed used to store (x,y,z) vector representation - * A Vector3 is the main object used in 3D geometry - * It can represent etiher the coordinates of a point the space, either a direction - * Reminder: Babylon.js uses a left handed forward facing system - * @public - */ -declare class Vector3 { - /** - * Defines the first coordinates (on X axis) - */ - x: number - /** - * Defines the second coordinates (on Y axis) - */ - y: number - /** - * Defines the third coordinates (on Z axis) - */ - z: number - /** - * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same - */ - readonly isNonUniform: boolean - /** - * Creates a new Vector3 object from the given x, y, z (floats) coordinates. - * @param x - defines the first coordinates (on X axis) - * @param y - defines the second coordinates (on Y axis) - * @param z - defines the third coordinates (on Z axis) - */ - constructor( - /** - * Defines the first coordinates (on X axis) - */ - x?: number, - /** - * Defines the second coordinates (on Y axis) - */ - y?: number, - /** - * Defines the third coordinates (on Z axis) - */ - z?: number - ) - /** - * Returns a new Vector3 as the result of the addition of the two given vectors. - * @param vector1 - the first vector - * @param vector2 - the second vector - * @returns the resulting vector - */ - static Add(vector1: ReadOnlyVector3, vector2: ReadOnlyVector3): Vector3 - /** - * Get the clip factor between two vectors - * @param vector0 - defines the first operand - * @param vector1 - defines the second operand - * @param axis - defines the axis to use - * @param size - defines the size along the axis - * @returns the clip factor - */ - static GetClipFactor(vector0: ReadOnlyVector3, vector1: ReadOnlyVector3, axis: ReadOnlyVector3, size: number): number - /** - * Get angle between two vectors - * @param vector0 - angle between vector0 and vector1 - * @param vector1 - angle between vector0 and vector1 - * @param normal - direction of the normal - * @returns the angle between vector0 and vector1 - */ - static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: ReadOnlyVector3): number - /** - * Returns a new Vector3 set from the index "offset" of the given array - * @param array - defines the source array - * @param offset - defines the offset in the source array - * @returns the new Vector3 - */ - static FromArray(array: ArrayLike, offset?: number): Vector3 - /** - * Returns a new Vector3 set from the index "offset" of the given FloatArray - * This function is deprecated. Use FromArray instead - * @param array - defines the source array - * @param offset - defines the offset in the source array - * @returns the new Vector3 - */ - static FromFloatArray(array: FloatArray, offset?: number): Vector3 - /** - * Sets the given vector "result" with the element values from the index "offset" of the given array - * @param array - defines the source array - * @param offset - defines the offset in the source array - * @param result - defines the Vector3 where to store the result - */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void - /** - * Sets the given vector "result" with the element values from the index "offset" of the given FloatArray - * This function is deprecated. Use FromArrayToRef instead. - * @param array - defines the source array - * @param offset - defines the offset in the source array - * @param result - defines the Vector3 where to store the result - */ - static FromFloatArrayToRef(array: FloatArray, offset: number, result: Vector3): void - /** - * Sets the given vector "result" with the given floats. - * @param x - defines the x coordinate of the source - * @param y - defines the y coordinate of the source - * @param z - defines the z coordinate of the source - * @param result - defines the Vector3 where to store the result - */ - static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void - /** - * Returns a new Vector3 set to (0.0, 0.0, 0.0) - * @returns a new empty Vector3 - */ - static Zero(): Vector3 - /** - * Returns a new Vector3 set to (1.0, 1.0, 1.0) - * @returns a new unit Vector3 - */ - static One(): Vector3 - /** - * Returns a new Vector3 set to (0.0, 1.0, 0.0) - * @returns a new up Vector3 - */ - static Up(): Vector3 - /** - * Returns a new Vector3 set to (0.0, -1.0, 0.0) - * @returns a new down Vector3 - */ - static Down(): Vector3 - /** - * Returns a new Vector3 set to (0.0, 0.0, 1.0) - * @returns a new forward Vector3 - */ - static Forward(): Vector3 - /** - * Returns a new Vector3 set to (0.0, 0.0, -1.0) - * @returns a new forward Vector3 - */ - static Backward(): Vector3 - /** - * Returns a new Vector3 set to (1.0, 0.0, 0.0) - * @returns a new right Vector3 - */ - static Right(): Vector3 - /** - * Returns a new Vector3 set to (-1.0, 0.0, 0.0) - * @returns a new left Vector3 - */ - static Left(): Vector3 - /** - * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector. - * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) - * @param vector - defines the Vector3 to transform - * @param transformation - defines the transformation matrix - * @returns the transformed Vector3 - */ - static TransformCoordinates(vector: ReadOnlyVector3, transformation: Matrix): Vector3 - /** - * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector - * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) - * @param vector - defines the Vector3 to transform - * @param transformation - defines the transformation matrix - * @param result - defines the Vector3 where to store the result - */ - static TransformCoordinatesToRef(vector: ReadOnlyVector3, transformation: Readonly, result: Vector3): void - /** - * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z) - * This method computes tranformed coordinates only, not transformed direction vectors - * @param x - define the x coordinate of the source vector - * @param y - define the y coordinate of the source vector - * @param z - define the z coordinate of the source vector - * @param transformation - defines the transformation matrix - * @param result - defines the Vector3 where to store the result - */ - static TransformCoordinatesFromFloatsToRef( - x: number, - y: number, - z: number, - transformation: Readonly, - result: Vector3 - ): void - /** - * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector - * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) - * @param vector - defines the Vector3 to transform - * @param transformation - defines the transformation matrix - * @returns the new Vector3 - */ - static TransformNormal(vector: ReadOnlyVector3, transformation: Matrix): Vector3 - /** - * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector - * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) - * @param vector - defines the Vector3 to transform - * @param transformation - defines the transformation matrix - * @param result - defines the Vector3 where to store the result - */ - static TransformNormalToRef(vector: ReadOnlyVector3, transformation: Readonly, result: Vector3): void - /** - * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z) - * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) - * @param x - define the x coordinate of the source vector - * @param y - define the y coordinate of the source vector - * @param z - define the z coordinate of the source vector - * @param transformation - defines the transformation matrix - * @param result - defines the Vector3 where to store the result - */ - static TransformNormalFromFloatsToRef( - x: number, - y: number, - z: number, - transformation: Readonly, - result: Vector3 - ): void - /** - * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4" - * @param value1 - defines the first control point - * @param value2 - defines the second control point - * @param value3 - defines the third control point - * @param value4 - defines the fourth control point - * @param amount - defines the amount on the spline to use - * @returns the new Vector3 - */ - static CatmullRom( - value1: ReadOnlyVector3, - value2: ReadOnlyVector3, - value3: ReadOnlyVector3, - value4: ReadOnlyVector3, - amount: number - ): Vector3 - /** - * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max" - * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one - * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one - * @param value - defines the current value - * @param min - defines the lower range value - * @param max - defines the upper range value - * @returns the new Vector3 - */ - static Clamp(value: ReadOnlyVector3, min: ReadOnlyVector3, max: ReadOnlyVector3): Vector3 - /** - * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max" - * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one - * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one - * @param value - defines the current value - * @param min - defines the lower range value - * @param max - defines the upper range value - * @param result - defines the Vector3 where to store the result - */ - static ClampToRef(value: ReadOnlyVector3, min: ReadOnlyVector3, max: ReadOnlyVector3, result: Vector3): void - /** - * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2" - * @param value1 - defines the first control point - * @param tangent1 - defines the first tangent vector - * @param value2 - defines the second control point - * @param tangent2 - defines the second tangent vector - * @param amount - defines the amount on the interpolation spline (between 0 and 1) - * @returns the new Vector3 - */ - static Hermite( - value1: ReadOnlyVector3, - tangent1: ReadOnlyVector3, - value2: ReadOnlyVector3, - tangent2: ReadOnlyVector3, - amount: number - ): Vector3 - /** - * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end" - * @param start - defines the start value - * @param end - defines the end value - * @param amount - max defines amount between both (between 0 and 1) - * @returns the new Vector3 - */ - static Lerp(start: ReadOnlyVector3, end: ReadOnlyVector3, amount: number): Vector3 - /** - * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end" - * @param start - defines the start value - * @param end - defines the end value - * @param amount - max defines amount between both (between 0 and 1) - * @param result - defines the Vector3 where to store the result - */ - static LerpToRef(start: ReadOnlyVector3, end: ReadOnlyVector3, amount: number, result: Vector3): void - /** - * Returns the dot product (float) between the vectors "left" and "right" - * @param left - defines the left operand - * @param right - defines the right operand - * @returns the dot product - */ - static Dot(left: ReadOnlyVector3, right: ReadOnlyVector3): number - /** - * Returns a new Vector3 as the cross product of the vectors "left" and "right" - * The cross product is then orthogonal to both "left" and "right" - * @param left - defines the left operand - * @param right - defines the right operand - * @returns the cross product - */ - static Cross(left: ReadOnlyVector3, right: ReadOnlyVector3): Vector3 - /** - * Sets the given vector "result" with the cross product of "left" and "right" - * The cross product is then orthogonal to both "left" and "right" - * @param left - defines the left operand - * @param right - defines the right operand - * @param result - defines the Vector3 where to store the result - */ - static CrossToRef(left: ReadOnlyVector3, right: ReadOnlyVector3, result: Vector3): void - /** - * Returns a new Vector3 as the normalization of the given vector - * @param vector - defines the Vector3 to normalize - * @returns the new Vector3 - */ - static Normalize(vector: Vector3): Vector3 - /** - * Sets the given vector "result" with the normalization of the given first vector - * @param vector - defines the Vector3 to normalize - * @param result - defines the Vector3 where to store the result - */ - static NormalizeToRef(vector: Vector3, result: Vector3): void - /** - * Gets the minimal coordinate values between two Vector3 - * @param left - defines the first operand - * @param right - defines the second operand - * @returns the new Vector3 - */ - static Minimize(left: ReadOnlyVector3, right: ReadOnlyVector3): Vector3 - /** - * Gets the maximal coordinate values between two Vector3 - * @param left - defines the first operand - * @param right - defines the second operand - * @returns the new Vector3 - */ - static Maximize(left: Vector3, right: Vector3): Vector3 - /** - * Returns the distance between the vectors "value1" and "value2" - * @param value1 - defines the first operand - * @param value2 - defines the second operand - * @returns the distance - */ - static Distance(value1: ReadOnlyVector3, value2: ReadOnlyVector3): number - /** - * Returns the squared distance between the vectors "value1" and "value2" - * @param value1 - defines the first operand - * @param value2 - defines the second operand - * @returns the squared distance - */ - static DistanceSquared(value1: ReadOnlyVector3, value2: ReadOnlyVector3): number - /** - * Returns a new Vector3 located at the center between "value1" and "value2" - * @param value1 - defines the first operand - * @param value2 - defines the second operand - * @returns the new Vector3 - */ - static Center(value1: ReadOnlyVector3, value2: ReadOnlyVector3): Vector3 - /** - * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), - * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply - * to something in order to rotate it from its local system to the given target system - * Note: axis1, axis2 and axis3 are normalized during this operation - * @param axis1 - defines the first axis - * @param axis2 - defines the second axis - * @param axis3 - defines the third axis - * @returns a new Vector3 - */ - static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3 - /** - * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3 - * @param axis1 - defines the first axis - * @param axis2 - defines the second axis - * @param axis3 - defines the third axis - * @param ref - defines the Vector3 where to store the result - */ - static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void - /** - * Creates a string representation of the Vector3 - * @returns a string with the Vector3 coordinates. - */ - toString(): string - /** - * Gets the class name - * @returns the string "Vector3" - */ - getClassName(): string - /** - * Creates the Vector3 hash code - * @returns a number which tends to be unique between Vector3 instances - */ - getHashCode(): number - /** - * Creates an array containing three elements : the coordinates of the Vector3 - * @returns a new array of numbers - */ - asArray(): number[] - /** - * Populates the given array or FloatArray from the given index with the successive coordinates of the Vector3 - * @param array - defines the destination array - * @param index - defines the offset in the destination array - * @returns the current Vector3 - */ - toArray(array: FloatArray, index?: number): Vector3 - /** - * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation) - * @returns a new Quaternion object, computed from the Vector3 coordinates - */ - toQuaternion(): Quaternion - /** - * Adds the given vector to the current Vector3 - * @param otherVector - defines the second operand - * @returns the current updated Vector3 - */ - addInPlace(otherVector: ReadOnlyVector3): Vector3 - /** - * Adds the given coordinates to the current Vector3 - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @returns the current updated Vector3 - */ - addInPlaceFromFloats(x: number, y: number, z: number): Vector3 - /** - * Gets a new Vector3, result of the addition the current Vector3 and the given vector - * @param otherVector - defines the second operand - * @returns the resulting Vector3 - */ - add(otherVector: ReadOnlyVector3): Vector3 - /** - * Adds the current Vector3 to the given one and stores the result in the vector "result" - * @param otherVector - defines the second operand - * @param result - defines the Vector3 object where to store the result - * @returns the current Vector3 - */ - addToRef(otherVector: ReadOnlyVector3, result: Vector3): Vector3 - /** - * Subtract the given vector from the current Vector3 - * @param otherVector - defines the second operand - * @returns the current updated Vector3 - */ - subtractInPlace(otherVector: ReadOnlyVector3): Vector3 - /** - * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3 - * @param otherVector - defines the second operand - * @returns the resulting Vector3 - */ - subtract(otherVector: ReadOnlyVector3): Vector3 - /** - * Subtracts the given vector from the current Vector3 and stores the result in the vector "result". - * @param otherVector - defines the second operand - * @param result - defines the Vector3 object where to store the result - * @returns the current Vector3 - */ - subtractToRef(otherVector: ReadOnlyVector3, result: Vector3): Vector3 - /** - * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @returns the resulting Vector3 - */ - subtractFromFloats(x: number, y: number, z: number): Vector3 - /** - * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @param result - defines the Vector3 object where to store the result - * @returns the current Vector3 - */ - subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3 - /** - * Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective - * @param matrix - The transformation matrix - */ - applyMatrix4(matrix: Matrix): void - /** - * Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective and set the given vector "result" with this result - * @param matrix - The transformation matrix - * @param result - defines the Vector3 object where to store the result - * @returns the current Vector3 - */ - applyMatrix4ToRef(matrix: Matrix, result: Vector3): Vector3 - /** - * Rotates the current Vector3 based on the given quaternion - * @param q - defines the Quaternion - * @returns the current Vector3 - */ - rotate(q: Quaternion): Vector3 - /** - * Rotates current Vector3 based on the given quaternion, but applies the rotation to target Vector3. - * @param q - defines the Quaternion - * @param result - defines the target Vector3 - * @returns the current Vector3 - */ - rotateToRef(q: Quaternion, result: Vector3): Vector3 - /** - * Gets a new Vector3 set with the current Vector3 negated coordinates - * @returns a new Vector3 - */ - negate(): Vector3 - /** - * Multiplies the Vector3 coordinates by the float "scale" - * @param scale - defines the multiplier factor - * @returns the current updated Vector3 - */ - scaleInPlace(scale: number): Vector3 - /** - * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale" - * @param scale - defines the multiplier factor - * @returns a new Vector3 - */ - scale(scale: number): Vector3 - /** - * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates - * @param scale - defines the multiplier factor - * @param result - defines the Vector3 object where to store the result - * @returns the current Vector3 - */ - scaleToRef(scale: number, result: Vector3): Vector3 - /** - * Scale the current Vector3 values by a factor and add the result to a given Vector3 - * @param scale - defines the scale factor - * @param result - defines the Vector3 object where to store the result - * @returns the unmodified current Vector3 - */ - scaleAndAddToRef(scale: number, result: Vector3): Vector3 - /** - * Returns true if the current Vector3 and the given vector coordinates are strictly equal - * @param otherVector - defines the second operand - * @returns true if both vectors are equals - */ - equals(otherVector: ReadOnlyVector3): boolean - /** - * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon - * @param otherVector - defines the second operand - * @param epsilon - defines the minimal distance to define values as equals - * @returns true if both vectors are distant less than epsilon - */ - equalsWithEpsilon(otherVector: ReadOnlyVector3, epsilon?: number): boolean - /** - * Returns true if the current Vector3 coordinates equals the given floats - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @returns true if both vectors are equals - */ - equalsToFloats(x: number, y: number, z: number): boolean - /** - * Multiplies the current Vector3 coordinates by the given ones - * @param otherVector - defines the second operand - * @returns the current updated Vector3 - */ - multiplyInPlace(otherVector: ReadOnlyVector3): Vector3 - /** - * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector - * @param otherVector - defines the second operand - * @returns the new Vector3 - */ - multiply(otherVector: ReadOnlyVector3): Vector3 - /** - * Multiplies the current Vector3 by the given one and stores the result in the given vector "result" - * @param otherVector - defines the second operand - * @param result - defines the Vector3 object where to store the result - * @returns the current Vector3 - */ - multiplyToRef(otherVector: ReadOnlyVector3, result: Vector3): Vector3 - /** - * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @returns the new Vector3 - */ - multiplyByFloats(x: number, y: number, z: number): Vector3 - /** - * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones - * @param otherVector - defines the second operand - * @returns the new Vector3 - */ - divide(otherVector: ReadOnlyVector3): Vector3 - /** - * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result" - * @param otherVector - defines the second operand - * @param result - defines the Vector3 object where to store the result - * @returns the current Vector3 - */ - divideToRef(otherVector: ReadOnlyVector3, result: Vector3): Vector3 - /** - * Divides the current Vector3 coordinates by the given ones. - * @param otherVector - defines the second operand - * @returns the current updated Vector3 - */ - divideInPlace(otherVector: ReadOnlyVector3): Vector3 - /** - * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones - * @param other - defines the second operand - * @returns the current updated Vector3 - */ - minimizeInPlace(other: ReadOnlyVector3): Vector3 - /** - * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones. - * @param other - defines the second operand - * @returns the current updated Vector3 - */ - maximizeInPlace(other: ReadOnlyVector3): Vector3 - /** - * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @returns the current updated Vector3 - */ - minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3 - /** - * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates. - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @returns the current updated Vector3 - */ - maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3 - /** - * Gets a new Vector3 from current Vector3 floored values - * @returns a new Vector3 - */ - floor(): Vector3 - /** - * Gets a new Vector3 from current Vector3 floored values - * @returns a new Vector3 - */ - fract(): Vector3 - /** - * Gets the length of the Vector3 - * @returns the length of the Vecto3 - */ - length(): number - /** - * Gets the squared length of the Vector3 - * @returns squared length of the Vector3 - */ - lengthSquared(): number - /** - * Normalize the current Vector3. - * Please note that this is an in place operation. - * @returns the current updated Vector3 - */ - normalize(): Vector3 - /** - * Normalize the current Vector3 with the given input length. - * Please note that this is an in place operation. - * @param len - the length of the vector - * @returns the current updated Vector3 - */ - normalizeFromLength(len: number): Vector3 - /** - * Normalize the current Vector3 to a new vector - * @returns the new Vector3 - */ - normalizeToNew(): Vector3 - /** - * Normalize the current Vector3 to the reference - * @param reference - define the Vector3 to update - * @returns the updated Vector3 - */ - normalizeToRef(reference: Vector3): Vector3 - /** - * Creates a new Vector3 copied from the current Vector3 - * @returns the new Vector3 - */ - clone(): Vector3 - /** - * Copies the given vector coordinates to the current Vector3 ones - * @param source - defines the source Vector3 - * @returns the current updated Vector3 - */ - copyFrom(source: ReadOnlyVector3): Vector3 - /** - * Copies the given floats to the current Vector3 coordinates - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @returns the current updated Vector3 - */ - copyFromFloats(x: number, y: number, z: number): Vector3 - /** - * Copies the given floats to the current Vector3 coordinates - * @param x - defines the x coordinate of the operand - * @param y - defines the y coordinate of the operand - * @param z - defines the z coordinate of the operand - * @returns the current updated Vector3 - */ - set(x: number, y: number, z: number): Vector3 - /** - * Copies the given float to the current Vector3 coordinates - * @param v - defines the x, y and z coordinates of the operand - * @returns the current updated Vector3 - */ - setAll(v: number): Vector3 -} - -/** - * Vector4 class created for EulerAngle class conversion to Quaternion - * @public - */ -declare class Vector4 { - /** x value of the vector */ - x: number - /** y value of the vector */ - y: number - /** z value of the vector */ - z: number - /** w value of the vector */ - w: number - /** - * Creates a Vector4 object from the given floats. - * @param x - x value of the vector - * @param y - y value of the vector - * @param z - z value of the vector - * @param w - w value of the vector - */ - constructor( - /** x value of the vector */ - x: number, - /** y value of the vector */ - y: number, - /** z value of the vector */ - z: number, - /** w value of the vector */ - w: number - ) - /** - * Returns a new Vector4 as the result of the addition of the two given vectors. - * @param vector1 - the first vector - * @param vector2 - the second vector - * @returns the resulting vector - */ - static Add(vector1: ReadOnlyVector4, vector2: ReadOnlyVector4): Vector4 - /** - * Returns a new Vector4 set from the starting index of the given array. - * @param array - the array to pull values from - * @param offset - the offset into the array to start at - * @returns the new vector - */ - static FromArray(array: ArrayLike, offset?: number): Vector4 - /** - * Updates the given vector "result" from the starting index of the given array. - * @param array - the array to pull values from - * @param offset - the offset into the array to start at - * @param result - the vector to store the result in - */ - static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void - /** - * Updates the given vector "result" from the starting index of the given FloatArray. - * @param array - the array to pull values from - * @param offset - the offset into the array to start at - * @param result - the vector to store the result in - */ - static FromFloatArrayToRef(array: FloatArray, offset: number, result: Vector4): void - /** - * Updates the given vector "result" coordinates from the given floats. - * @param x - float to set from - * @param y - float to set from - * @param z - float to set from - * @param w - float to set from - * @param result - the vector to the floats in - */ - static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void - /** - * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) - * @returns the new vector - */ - static Zero(): Vector4 - /** - * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) - * @returns the new vector - */ - static One(): Vector4 - /** - * Returns a new normalized Vector4 from the given one. - * @param vector - the vector to normalize - * @returns the vector - */ - static Normalize(vector: ReadOnlyVector4): Vector4 - /** - * Updates the given vector "result" from the normalization of the given one. - * @param vector - the vector to normalize - * @param result - the vector to store the result in - */ - static NormalizeToRef(vector: ReadOnlyVector4, result: Vector4): void - /** - * Returns a vector with the minimum values from the left and right vectors - * @param left - left vector to minimize - * @param right - right vector to minimize - * @returns a new vector with the minimum of the left and right vector values - */ - static Minimize(left: ReadOnlyVector4, right: ReadOnlyVector4): Vector4 - /** - * Returns a vector with the maximum values from the left and right vectors - * @param left - left vector to maximize - * @param right - right vector to maximize - * @returns a new vector with the maximum of the left and right vector values - */ - static Maximize(left: ReadOnlyVector4, right: ReadOnlyVector4): Vector4 - /** - * Returns the distance (float) between the vectors "value1" and "value2". - * @param value1 - value to calulate the distance between - * @param value2 - value to calulate the distance between - * @returns the distance between the two vectors - */ - static Distance(value1: ReadOnlyVector4, value2: ReadOnlyVector4): number - /** - * Returns the squared distance (float) between the vectors "value1" and "value2". - * @param value1 - value to calulate the distance between - * @param value2 - value to calulate the distance between - * @returns the distance between the two vectors squared - */ - static DistanceSquared(value1: ReadOnlyVector4, value2: ReadOnlyVector4): number - /** - * Returns a new Vector4 located at the center between the vectors "value1" and "value2". - * @param value1 - value to calulate the center between - * @param value2 - value to calulate the center between - * @returns the center between the two vectors - */ - static Center(value1: ReadOnlyVector4, value2: ReadOnlyVector4): Vector4 - /** - * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector. - * This methods computes transformed normalized direction vectors only. - * @param vector - the vector to transform - * @param transformation - the transformation matrix to apply - * @returns the new vector - */ - static TransformNormal(vector: ReadOnlyVector4, transformation: Matrix): Vector4 - /** - * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector. - * This methods computes transformed normalized direction vectors only. - * @param vector - the vector to transform - * @param transformation - the transformation matrix to apply - * @param result - the vector to store the result in - */ - static TransformNormalToRef(vector: ReadOnlyVector4, transformation: Matrix, result: Vector4): void - /** - * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w). - * This methods computes transformed normalized direction vectors only. - * @param x - value to transform - * @param y - value to transform - * @param z - value to transform - * @param w - value to transform - * @param transformation - the transformation matrix to apply - * @param result - the vector to store the results in - */ - static TransformNormalFromFloatsToRef( - x: number, - y: number, - z: number, - w: number, - transformation: Matrix, - result: Vector4 - ): void - /** - * Returns the string with the Vector4 coordinates. - * @returns a string containing all the vector values - */ - toString(): string - /** - * Returns the string "Vector4". - * @returns "Vector4" - */ - getClassName(): string - /** - * Returns the Vector4 hash code. - * @returns a unique hash code - */ - getHashCode(): number - /** - * Returns a new array populated with 4 elements : the Vector4 coordinates. - * @returns the resulting array - */ - asArray(): number[] - /** - * Populates the given array from the given index with the Vector4 coordinates. - * @param array - array to populate - * @param index - index of the array to start at (default: 0) - * @returns the Vector4. - */ - toArray(array: FloatArray, index?: number): Vector4 - /** - * Adds the given vector to the current Vector4. - * @param otherVector - the vector to add - * @returns the updated Vector4. - */ - addInPlace(otherVector: ReadOnlyVector4): Vector4 - /** - * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one. - * @param otherVector - the vector to add - * @returns the resulting vector - */ - add(otherVector: ReadOnlyVector4): Vector4 - /** - * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one. - * @param otherVector - the vector to add - * @param result - the vector to store the result - * @returns the current Vector4. - */ - addToRef(otherVector: ReadOnlyVector4, result: Vector4): Vector4 - /** - * Subtract in place the given vector from the current Vector4. - * @param otherVector - the vector to subtract - * @returns the updated Vector4. - */ - subtractInPlace(otherVector: ReadOnlyVector4): Vector4 - /** - * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4. - * @param otherVector - the vector to add - * @returns the new vector with the result - */ - subtract(otherVector: ReadOnlyVector4): Vector4 - /** - * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4. - * @param otherVector - the vector to subtract - * @param result - the vector to store the result - * @returns the current Vector4. - */ - subtractToRef(otherVector: ReadOnlyVector4, result: Vector4): Vector4 - /** - * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates. - */ - /** - * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates. - * @param x - value to subtract - * @param y - value to subtract - * @param z - value to subtract - * @param w - value to subtract - * @returns new vector containing the result - */ - subtractFromFloats(x: number, y: number, z: number, w: number): Vector4 - /** - * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates. - * @param x - value to subtract - * @param y - value to subtract - * @param z - value to subtract - * @param w - value to subtract - * @param result - the vector to store the result in - * @returns the current Vector4. - */ - subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4 - /** - * Returns a new Vector4 set with the current Vector4 negated coordinates. - * @returns a new vector with the negated values - */ - negate(): Vector4 - /** - * Multiplies the current Vector4 coordinates by scale (float). - * @param scale - the number to scale with - * @returns the updated Vector4. - */ - scaleInPlace(scale: number): Vector4 - /** - * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). - * @param scale - the number to scale with - * @returns a new vector with the result - */ - scale(scale: number): Vector4 - /** - * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float). - * @param scale - the number to scale with - * @param result - a vector to store the result in - * @returns the current Vector4. - */ - scaleToRef(scale: number, result: Vector4): Vector4 - /** - * Scale the current Vector4 values by a factor and add the result to a given Vector4 - * @param scale - defines the scale factor - * @param result - defines the Vector4 object where to store the result - * @returns the unmodified current Vector4 - */ - scaleAndAddToRef(scale: number, result: Vector4): Vector4 - /** - * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones. - * @param otherVector - the vector to compare against - * @returns true if they are equal - */ - equals(otherVector: ReadOnlyVector4): boolean - /** - * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones. - * @param otherVector - vector to compare against - * @param epsilon - (Default: very small number) - * @returns true if they are equal - */ - equalsWithEpsilon(otherVector: ReadOnlyVector4, epsilon?: number): boolean - /** - * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates. - * @param x - x value to compare against - * @param y - y value to compare against - * @param z - z value to compare against - * @param w - w value to compare against - * @returns true if equal - */ - equalsToFloats(x: number, y: number, z: number, w: number): boolean - /** - * Multiplies in place the current Vector4 by the given one. - * @param otherVector - vector to multiple with - * @returns the updated Vector4. - */ - multiplyInPlace(otherVector: ReadOnlyVector4): Vector4 - /** - * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one. - * @param otherVector - vector to multiple with - * @returns resulting new vector - */ - multiply(otherVector: ReadOnlyVector4): Vector4 - /** - * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one. - * @param otherVector - vector to multiple with - * @param result - vector to store the result - * @returns the current Vector4. - */ - multiplyToRef(otherVector: ReadOnlyVector4, result: Vector4): Vector4 - /** - * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates. - * @param x - x value multiply with - * @param y - y value multiply with - * @param z - z value multiply with - * @param w - w value multiply with - * @returns resulting new vector - */ - multiplyByFloats(x: number, y: number, z: number, w: number): Vector4 - /** - * Returns a new Vector4 set with the division result of the current Vector4 by the given one. - * @param otherVector - vector to devide with - * @returns resulting new vector - */ - divide(otherVector: ReadOnlyVector4): Vector4 - /** - * Updates the given vector "result" with the division result of the current Vector4 by the given one. - * @param otherVector - vector to devide with - * @param result - vector to store the result - * @returns the current Vector4. - */ - divideToRef(otherVector: ReadOnlyVector4, result: Vector4): Vector4 - /** - * Divides the current Vector3 coordinates by the given ones. - * @param otherVector - vector to devide with - * @returns the updated Vector3. - */ - divideInPlace(otherVector: ReadOnlyVector4): Vector4 - /** - * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones - * @param other - defines the second operand - * @returns the current updated Vector4 - */ - minimizeInPlace(other: ReadOnlyVector4): Vector4 - /** - * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones - * @param other - defines the second operand - * @returns the current updated Vector4 - */ - maximizeInPlace(other: ReadOnlyVector4): Vector4 - /** - * Gets a new Vector4 from current Vector4 floored values - * @returns a new Vector4 - */ - floor(): Vector4 - /** - * Gets a new Vector4 from current Vector3 floored values - * @returns a new Vector4 - */ - fract(): Vector4 - /** - * Returns the Vector4 length (float). - * @returns the length - */ - length(): number - /** - * Returns the Vector4 squared length (float). - * @returns the length squared - */ - lengthSquared(): number - /** - * Normalizes in place the Vector4. - * @returns the updated Vector4. - */ - normalize(): Vector4 - /** - * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. - * @returns this converted to a new vector3 - */ - toVector3(): Vector3 - /** - * Returns a new Vector4 copied from the current one. - * @returns the new cloned vector - */ - clone(): Vector4 - /** - * Updates the current Vector4 with the given one coordinates. - * @param source - the source vector to copy from - * @returns the updated Vector4. - */ - copyFrom(source: ReadOnlyVector4): Vector4 - /** - * Updates the current Vector4 coordinates with the given floats. - * @param x - float to copy from - * @param y - float to copy from - * @param z - float to copy from - * @param w - float to copy from - * @returns the updated Vector4. - */ - copyFromFloats(x: number, y: number, z: number, w: number): Vector4 - /** - * Updates the current Vector4 coordinates with the given floats. - * @param x - float to set from - * @param y - float to set from - * @param z - float to set from - * @param w - float to set from - * @returns the updated Vector4. - */ - set(x: number, y: number, z: number, w: number): Vector4 - /** - * Copies the given float to the current Vector3 coordinates - * @param v - defines the x, y, z and w coordinates of the operand - * @returns the current updated Vector3 - */ - setAll(v: number): Vector4 -} - -declare type double = number - -declare const engine: Engine - -/** - * Error function. Prints a console error. Only works in debug mode, otherwise it does nothing. - * @param error - string or Error object. - * @param data - any debug information. - * @public - */ -declare function error(error: string | Error, data?: any): void - -/** - * Executes an asynchronous task - * @param task - the task to execute - * @beta - */ -declare function executeTask(task: () => Promise): TaskResult - -declare type float = number - -/** - * @public - */ -declare function getComponentClassId = any>( - component: T | ComponentConstructor -): number | null - -/** - * @public - */ -declare function getComponentId(component: T): string - -/** - * @public - */ -declare function getComponentName = any>(component: T | ComponentConstructor): string - -/** - * @public - */ -declare function isDisposableComponent(component: ComponentLike): boolean - -/** - * Log function. Only works in debug mode, otherwise it does nothing. - * @param args - any loggable parameter - * @public - */ -declare function log(...args: any[]): void +/** + * Defines angle representation + * @public + */ +declare class Angle { + private _radians + /** + * Creates an Angle object of "radians" radians (float). + */ + constructor(radians: number) + /** + * Gets a new Angle object valued with the angle value in radians between the two given vectors + * @param a - defines first vector + * @param b - defines second vector + * @returns a new Angle + */ + static BetweenTwoPoints(a: Vector2, b: Vector2): Angle + /** + * Gets a new Angle object from the given float in radians + * @param radians - defines the angle value in radians + * @returns a new Angle + */ + static FromRadians(radians: number): Angle + /** + * Gets a new Angle object from the given float in degrees + * @param degrees - defines the angle value in degrees + * @returns a new Angle + */ + static FromDegrees(degrees: number): Angle + /** + * Get value in degrees + * @returns the Angle value in degrees (float) + */ + degrees(): number + /** + * Get value in radians + * @returns the Angle value in radians (float) + */ + radians(): number +} + +/** + * @public + */ +declare class AnimationClip extends ObservableComponent { + /** + * Name of the animation in the model + */ + readonly clip: string + /** + * Does the animation loop?, default: true + */ + looping: boolean + /** + * Weight of the animation, values from 0 to 1, used to blend several animations. default: 1 + */ + weight: number + /** + * Is the animation playing? default: true + */ + playing: boolean + /** + * The animation speed + */ + speed: number + constructor(clip: string, params?: AnimationParams) + /** + * Sets the clip parameters + */ + setParams(params: AnimationParams): void + /** + * Starts the animation + */ + play(): void + /** + * Pauses the animation + */ + pause(): void +} + +declare type AnimationParams = { + looping?: boolean + speed?: number + weight?: number +} + +/** + * @public + */ +declare class Animator extends Shape { + private states + /** + * Adds an AnimationClip to the animation lists. + */ + addClip(clip: AnimationClip): void + /** + * Gets the animation clip instance for the specified clip name. + * If the clip doesn't exist a new one will be created. + */ + getClip(clipName: string): AnimationClip +} + +/** + * This represents an arc in a 2d space. + * @public + */ +declare class Arc2 { + /** Defines the start point of the arc */ + startPoint: Vector2 + /** Defines the mid point of the arc */ + midPoint: Vector2 + /** Defines the end point of the arc */ + endPoint: Vector2 + /** + * Defines the center point of the arc. + */ + centerPoint: Vector2 + /** + * Defines the radius of the arc. + */ + radius: number + /** + * Defines the angle of the arc (from mid point to end point). + */ + angle: Angle + /** + * Defines the start angle of the arc (from start point to middle point). + */ + startAngle: Angle + /** + * Defines the orientation of the arc (clock wise/counter clock wise). + */ + orientation: Orientation + /** + * Creates an Arc object from the three given points : start, middle and end. + * @param startPoint - Defines the start point of the arc + * @param midPoint - Defines the midlle point of the arc + * @param endPoint - Defines the end point of the arc + */ + constructor( + /** Defines the start point of the arc */ + startPoint: Vector2, + /** Defines the mid point of the arc */ + midPoint: Vector2, + /** Defines the end point of the arc */ + endPoint: Vector2 + ) +} + +/** + * @public + */ +declare class AudioClip extends ObservableComponent { + readonly url: string + /** + * Is this clip looping by default? + */ + loop: boolean + /** + * Clip's master volume. This volume affects all the AudioSources. + * Valid ranges from 0 to 1 + */ + volume: number + constructor(url: string) +} + +/** + * @public + */ +declare class AudioSource extends ObservableComponent { + readonly audioClip: AudioClip + readonly audioClipId: string + /** + * Is this clip looping by default? + */ + loop: boolean + /** + * Clip's master volume. This volume affects all the AudioSources. + * Valid ranges from 0 to 1 + */ + volume: number + /** + * Is this AudioSource playing? + */ + playing: boolean + /** + * Pitch, default: 1.0, range from 0.0 to MaxFloat + */ + pitch: number + constructor(audioClip: AudioClip) + /** + * Disables the looping and plays the current source once. + * If the sound was playing, it stops and starts over. + */ + playOnce(): void +} + +/** + * Defines the 3 main axes + * @public + */ +declare class Axis { + /** X axis */ + static X: Vector3 + /** Y axis */ + static Y: Vector3 + /** Z axis */ + static Z: Vector3 +} + +/** + * @public + */ +declare class BasicMaterial extends ObservableComponent { + /** + * The source of the texture image. + */ + texture: string + /** + * A number between 0 and 1. + * Any pixel with an alpha lower than this value will be shown as transparent. + */ + alphaTest: number + /** + * Enables crisper images based on the provided sampling mode. + * | Value | Type | + * |-------|-----------| + * | 1 | NEAREST | + * | 2 | BILINEAR | + * | 3 | TRILINEAR | + */ + samplingMode: number + /** + * Enables texture wrapping for this material. + * | Value | Type | + * |-------|-----------| + * | 1 | CLAMP | + * | 2 | WRAP | + * | 3 | MIRROR | + */ + wrap: number +} + +/** + * Class used to represent a Bezier curve + * @public + */ +declare class BezierCurve { + /** + * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats + * @param t - defines the time + * @param x1 - defines the left coordinate on X axis + * @param y1 - defines the left coordinate on Y axis + * @param x2 - defines the right coordinate on X axis + * @param y2 - defines the right coordinate on Y axis + * @returns the interpolated value + */ + static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number +} + +/** + * Billboard defines a behavior that makes the entity face the camera in any moment. + * @public + */ +declare class Billboard extends ObservableComponent { + x: boolean + y: boolean + z: boolean + constructor(x?: boolean, y?: boolean, z?: boolean) +} + +/** + * @public + */ +declare class BoxShape extends Shape {} + +/** + * @public + */ +declare class Camera { + static readonly instance: Camera + readonly position: Vector3 + readonly rotation: Quaternion + constructor() +} + +/** + * @public + */ +declare class CircleShape extends Shape { + segments?: number + arc?: number +} + +/** + * Class used to hold a RBG color + * @public + */ +declare class Color3 { + /** + * Defines the red component (between 0 and 1, default is 0) + */ + r: number + /** + * Defines the green component (between 0 and 1, default is 0) + */ + g: number + /** + * Defines the blue component (between 0 and 1, default is 0) + */ + b: number + /** + * Creates a new Color3 object from red, green, blue values, all between 0 and 1 + * @param r - defines the red component (between 0 and 1, default is 0) + * @param g - defines the green component (between 0 and 1, default is 0) + * @param b - defines the blue component (between 0 and 1, default is 0) + */ + constructor( + /** + * Defines the red component (between 0 and 1, default is 0) + */ + r?: number, + /** + * Defines the green component (between 0 and 1, default is 0) + */ + g?: number, + /** + * Defines the blue component (between 0 and 1, default is 0) + */ + b?: number + ) + /** + * Creates a new Color3 from the string containing valid hexadecimal values + * @param hex - defines a string containing valid hexadecimal values + * @returns a new Color3 object + */ + static FromHexString(hex: string): Color3 + /** + * Creates a new Vector3 from the starting index of the given array + * @param array - defines the source array + * @param offset - defines an offset in the source array + * @returns a new Color3 object + */ + static FromArray(array: ArrayLike, offset?: number): Color3 + /** + * Creates a new Color3 from integer values (less than 256) + * @param r - defines the red component to read from (value between 0 and 255) + * @param g - defines the green component to read from (value between 0 and 255) + * @param b - defines the blue component to read from (value between 0 and 255) + * @returns a new Color3 object + */ + static FromInts(r: number, g: number, b: number): Color3 + /** + * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3 + * @param start - defines the start Color3 value + * @param end - defines the end Color3 value + * @param amount - defines the gradient value between start and end + * @returns a new Color3 object + */ + static Lerp(start: Color3, end: Color3, amount: number): Color3 + /** + * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3 + * @param left - defines the start value + * @param right - defines the end value + * @param amount - defines the gradient factor + * @param result - defines the Color3 object where to store the result + */ + static LerpToRef(left: Color3, right: Color3, amount: number, result: Color3): void + /** + * Returns a Color3 value containing a red color + * @returns a new Color3 object + */ + static Red(): Color3 + /** + * Returns a Color3 value containing a green color + * @returns a new Color3 object + */ + static Green(): Color3 + /** + * Returns a Color3 value containing a blue color + * @returns a new Color3 object + */ + static Blue(): Color3 + /** + * Returns a Color3 value containing a black color + * @returns a new Color3 object + */ + static Black(): Color3 + /** + * Returns a Color3 value containing a white color + * @returns a new Color3 object + */ + static White(): Color3 + /** + * Returns a Color3 value containing a purple color + * @returns a new Color3 object + */ + static Purple(): Color3 + /** + * Returns a Color3 value containing a magenta color + * @returns a new Color3 object + */ + static Magenta(): Color3 + /** + * Returns a Color3 value containing a yellow color + * @returns a new Color3 object + */ + static Yellow(): Color3 + /** + * Returns a Color3 value containing a gray color + * @returns a new Color3 object + */ + static Gray(): Color3 + /** + * Returns a Color3 value containing a teal color + * @returns a new Color3 object + */ + static Teal(): Color3 + /** + * Returns a Color3 value containing a random color + * @returns a new Color3 object + */ + static Random(): Color3 + /** + * Creates a string with the Color3 current values + * @returns the string representation of the Color3 object + */ + toString(): string + /** + * Returns the string "Color3" + * @returns "Color3" + */ + getClassName(): string + /** + * Compute the Color3 hash code + * @returns an unique number that can be used to hash Color3 objects + */ + getHashCode(): number + /** + * Stores in the given array from the given starting index the red, green, blue values as successive elements + * @param array - defines the array where to store the r,g,b components + * @param index - defines an optional index in the target array to define where to start storing values + * @returns the current Color3 object + */ + toArray(array: FloatArray, index?: number): Color3 + /** + * Returns a new Color4 object from the current Color3 and the given alpha + * @param alpha - defines the alpha component on the new Color4 object (default is 1) + * @returns a new Color4 object + */ + toColor4(alpha?: number): Color4 + /** + * Returns a new array populated with 3 numeric elements : red, green and blue values + * @returns the new array + */ + asArray(): number[] + /** + * Returns the luminance value + * @returns a float value + */ + toLuminance(): number + /** + * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object + * @param otherColor - defines the second operand + * @returns the new Color3 object + */ + multiply(otherColor: Color3): Color3 + /** + * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result" + * @param otherColor - defines the second operand + * @param result - defines the Color3 object where to store the result + * @returns the current Color3 + */ + multiplyToRef(otherColor: Color3, result: Color3): Color3 + /** + * Determines equality between Color3 objects + * @param otherColor - defines the second operand + * @returns true if the rgb values are equal to the given ones + */ + equals(otherColor: Color3): boolean + /** + * Determines equality between the current Color3 object and a set of r,b,g values + * @param r - defines the red component to check + * @param g - defines the green component to check + * @param b - defines the blue component to check + * @returns true if the rgb values are equal to the given ones + */ + equalsFloats(r: number, g: number, b: number): boolean + /** + * Multiplies in place each rgb value by scale + * @param scale - defines the scaling factor + * @returns the updated Color3 + */ + scale(scale: number): Color3 + /** + * Multiplies the rgb values by scale and stores the result into "result" + * @param scale - defines the scaling factor + * @param result - defines the Color3 object where to store the result + * @returns the unmodified current Color3 + */ + scaleToRef(scale: number, result: Color3): Color3 + /** + * Scale the current Color3 values by a factor and add the result to a given Color3 + * @param scale - defines the scale factor + * @param result - defines color to store the result into + * @returns the unmodified current Color3 + */ + scaleAndAddToRef(scale: number, result: Color3): Color3 + /** + * Clamps the rgb values by the min and max values and stores the result into "result" + * @param min - defines minimum clamping value (default is 0) + * @param max - defines maximum clamping value (default is 1) + * @param result - defines color to store the result into + * @returns the original Color3 + */ + clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3 + /** + * Creates a new Color3 set with the added values of the current Color3 and of the given one + * @param otherColor - defines the second operand + * @returns the new Color3 + */ + add(otherColor: Color3): Color3 + /** + * Stores the result of the addition of the current Color3 and given one rgb values into "result" + * @param otherColor - defines the second operand + * @param result - defines Color3 object to store the result into + * @returns the unmodified current Color3 + */ + addToRef(otherColor: Color3, result: Color3): Color3 + /** + * Returns a new Color3 set with the subtracted values of the given one from the current Color3 + * @param otherColor - defines the second operand + * @returns the new Color3 + */ + subtract(otherColor: Color3): Color3 + /** + * Stores the result of the subtraction of given one from the current Color3 rgb values into "result" + * @param otherColor - defines the second operand + * @param result - defines Color3 object to store the result into + * @returns the unmodified current Color3 + */ + subtractToRef(otherColor: Color3, result: Color3): Color3 + /** + * Copy the current object + * @returns a new Color3 copied the current one + */ + clone(): Color3 + /** + * Copies the rgb values from the source in the current Color3 + * @param source - defines the source Color3 object + * @returns the updated Color3 object + */ + copyFrom(source: Color3): Color3 + /** + * Updates the Color3 rgb values from the given floats + * @param r - defines the red component to read from + * @param g - defines the green component to read from + * @param b - defines the blue component to read from + * @returns the current Color3 object + */ + copyFromFloats(r: number, g: number, b: number): Color3 + /** + * Updates the Color3 rgb values from the given floats + * @param r - defines the red component to read from + * @param g - defines the green component to read from + * @param b - defines the blue component to read from + * @returns the current Color3 object + */ + set(r: number, g: number, b: number): Color3 + /** + * Compute the Color3 hexadecimal code as a string + * @returns a string containing the hexadecimal representation of the Color3 object + */ + toHexString(): string + /** + * Computes a new Color3 converted from the current one to linear space + * @returns a new Color3 object + */ + toLinearSpace(): Color3 + /** + * Converts the Color3 values to linear space and stores the result in "convertedColor" + * @param convertedColor - defines the Color3 object where to store the linear space version + * @returns the unmodified Color3 + */ + toLinearSpaceToRef(convertedColor: Color3): Color3 + /** + * Computes a new Color3 converted from the current one to gamma space + * @returns a new Color3 object + */ + toGammaSpace(): Color3 + /** + * Converts the Color3 values to gamma space and stores the result in "convertedColor" + * @param convertedColor - defines the Color3 object where to store the gamma space version + * @returns the unmodified Color3 + */ + toGammaSpaceToRef(convertedColor: Color3): Color3 + /** + * Serializes Color3 + */ + toJSON(): string +} + +/** + * Class used to hold a RBGA color + * @public + */ +declare class Color4 { + /** + * Defines the red component (between 0 and 1, default is 0) + */ + r: number + /** + * Defines the green component (between 0 and 1, default is 0) + */ + g: number + /** + * Defines the blue component (between 0 and 1, default is 0) + */ + b: number + /** + * Defines the alpha component (between 0 and 1, default is 1) + */ + a: number + /** + * Creates a new Color4 object from red, green, blue values, all between 0 and 1 + * @param r - defines the red component (between 0 and 1, default is 0) + * @param g - defines the green component (between 0 and 1, default is 0) + * @param b - defines the blue component (between 0 and 1, default is 0) + * @param a - defines the alpha component (between 0 and 1, default is 1) + */ + constructor( + /** + * Defines the red component (between 0 and 1, default is 0) + */ + r?: number, + /** + * Defines the green component (between 0 and 1, default is 0) + */ + g?: number, + /** + * Defines the blue component (between 0 and 1, default is 0) + */ + b?: number, + /** + * Defines the alpha component (between 0 and 1, default is 1) + */ + a?: number + ) + /** + * Creates a new Color4 from the string containing valid hexadecimal values + * @param hex - defines a string containing valid hexadecimal values + * @returns a new Color4 object + */ + static FromHexString(hex: string): Color4 + /** + * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object + * @param left - defines the start value + * @param right - defines the end value + * @param amount - defines the gradient factor + * @returns a new Color4 object + */ + static Lerp(left: Color4, right: Color4, amount: number): Color4 + /** + * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object + * @param left - defines the start value + * @param right - defines the end value + * @param amount - defines the gradient factor + * @param result - defines the Color4 object where to store data + */ + static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void + /** + * Creates a new Color4 from a Color3 and an alpha value + * @param color3 - defines the source Color3 to read from + * @param alpha - defines the alpha component (1.0 by default) + * @returns a new Color4 object + */ + static FromColor3(color3: Color3, alpha?: number): Color4 + /** + * Creates a new Color4 from the starting index element of the given array + * @param array - defines the source array to read from + * @param offset - defines the offset in the source array + * @returns a new Color4 object + */ + static FromArray(array: ArrayLike, offset?: number): Color4 + /** + * Creates a new Color3 from integer values (less than 256) + * @param r - defines the red component to read from (value between 0 and 255) + * @param g - defines the green component to read from (value between 0 and 255) + * @param b - defines the blue component to read from (value between 0 and 255) + * @param a - defines the alpha component to read from (value between 0 and 255) + * @returns a new Color3 object + */ + static FromInts(r: number, g: number, b: number, a: number): Color4 + /** + * Check the content of a given array and convert it to an array containing RGBA data + * If the original array was already containing count * 4 values then it is returned directly + * @param colors - defines the array to check + * @param count - defines the number of RGBA data to expect + * @returns an array containing count * 4 values (RGBA) + */ + static CheckColors4(colors: number[], count: number): number[] + /** + * Adds in place the given Color4 values to the current Color4 object + * @param right - defines the second operand + * @returns the current updated Color4 object + */ + addInPlace(right: Color4): Color4 + /** + * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values + * @returns the new array + */ + asArray(): number[] + /** + * Stores from the starting index in the given array the Color4 successive values + * @param array - defines the array where to store the r,g,b components + * @param index - defines an optional index in the target array to define where to start storing values + * @returns the current Color4 object + */ + toArray(array: number[], index?: number): Color4 + /** + * Creates a new Color4 set with the added values of the current Color4 and of the given one + * @param right - defines the second operand + * @returns a new Color4 object + */ + add(right: Color4): Color4 + /** + * Creates a new Color4 set with the subtracted values of the given one from the current Color4 + * @param right - defines the second operand + * @returns a new Color4 object + */ + subtract(right: Color4): Color4 + /** + * Subtracts the given ones from the current Color4 values and stores the results in "result" + * @param right - defines the second operand + * @param result - defines the Color4 object where to store the result + * @returns the current Color4 object + */ + subtractToRef(right: Color4, result: Color4): Color4 + /** + * Creates a new Color4 with the current Color4 values multiplied by scale + * @param scale - defines the scaling factor to apply + * @returns a new Color4 object + */ + scale(scale: number): Color4 + /** + * Multiplies the current Color4 values by scale and stores the result in "result" + * @param scale - defines the scaling factor to apply + * @param result - defines the Color4 object where to store the result + * @returns the current unmodified Color4 + */ + scaleToRef(scale: number, result: Color4): Color4 + /** + * Scale the current Color4 values by a factor and add the result to a given Color4 + * @param scale - defines the scale factor + * @param result - defines the Color4 object where to store the result + * @returns the unmodified current Color4 + */ + scaleAndAddToRef(scale: number, result: Color4): Color4 + /** + * Clamps the rgb values by the min and max values and stores the result into "result" + * @param min - defines minimum clamping value (default is 0) + * @param max - defines maximum clamping value (default is 1) + * @param result - defines color to store the result into. + * @returns the cuurent Color4 + */ + clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4 + /** + * Multipy an Color4 value by another and return a new Color4 object + * @param color - defines the Color4 value to multiply by + * @returns a new Color4 object + */ + multiply(color: Color4): Color4 + /** + * Multipy a Color4 value by another and push the result in a reference value + * @param color - defines the Color4 value to multiply by + * @param result - defines the Color4 to fill the result in + * @returns the result Color4 + */ + multiplyToRef(color: Color4, result: Color4): Color4 + /** + * Creates a string with the Color4 current values + * @returns the string representation of the Color4 object + */ + toString(): string + /** + * Returns the string "Color4" + * @returns "Color4" + */ + getClassName(): string + /** + * Compute the Color4 hash code + * @returns an unique number that can be used to hash Color4 objects + */ + getHashCode(): number + /** + * Creates a new Color4 copied from the current one + * @returns a new Color4 object + */ + clone(): Color4 + /** + * Copies the given Color4 values into the current one + * @param source - defines the source Color4 object + * @returns the current updated Color4 object + */ + copyFrom(source: Color4): Color4 + /** + * Copies the given float values into the current one + * @param r - defines the red component to read from + * @param g - defines the green component to read from + * @param b - defines the blue component to read from + * @param a - defines the alpha component to read from + * @returns the current updated Color4 object + */ + copyFromFloats(r: number, g: number, b: number, a: number): Color4 + /** + * Copies the given float values into the current one + * @param r - defines the red component to read from + * @param g - defines the green component to read from + * @param b - defines the blue component to read from + * @param a - defines the alpha component to read from + * @returns the current updated Color4 object + */ + set(r: number, g: number, b: number, a: number): Color4 + /** + * Compute the Color4 hexadecimal code as a string + * @returns a string containing the hexadecimal representation of the Color4 object + */ + toHexString(): string + /** + * Computes a new Color4 converted from the current one to linear space + * @returns a new Color4 object + */ + toLinearSpace(): Color4 + /** + * Converts the Color4 values to linear space and stores the result in "convertedColor" + * @param convertedColor - defines the Color4 object where to store the linear space version + * @returns the unmodified Color4 + */ + toLinearSpaceToRef(convertedColor: Color4): Color4 + /** + * Computes a new Color4 converted from the current one to gamma space + * @returns a new Color4 object + */ + toGammaSpace(): Color4 + /** + * Converts the Color4 values to gamma space and stores the result in "convertedColor" + * @param convertedColor - defines the Color4 object where to store the gamma space version + * @returns the unmodified Color4 + */ + toGammaSpaceToRef(convertedColor: Color4): Color4 +} + +/** + * @public + */ +declare function Component( + componentName: string, + classId?: number +): >(target: TFunction) => void | TFunction + +/** + * @public + */ +declare class ComponentAdded { + entity: Entity + componentName: string + classId: number | null + constructor(entity: Entity, componentName: string, classId: number | null) +} + +/** + * @public + */ +declare interface ComponentConstructor { + isComponent?: boolean + originalClassName?: string + new (...args: any[]): T +} + +/** + * @public + */ +declare class ComponentGroup { + readonly entities: ReadonlyArray + readonly requires: ReadonlyArray> + readonly requiresNames: ReadonlyArray + active: boolean + private _requiresNames + constructor(...requires: ComponentConstructor[]) + hasEntity(entity: Entity): boolean +} + +/** + * @public + */ +declare interface ComponentLike {} + +/** + * @public + */ +declare class ComponentRemoved { + entity: Entity + componentName: string + component: ComponentLike + constructor(entity: Entity, componentName: string, component: ComponentLike) +} + +/** + * @public + */ +declare class ConeShape extends Shape { + /** + * The radius of the top of a truncated cone. Defaults to 0. + */ + radiusTop: number + /** + * The radius of the base of the cone. Defaults to 1. + */ + radiusBottom: number + /** + * Sets the number of rings along the cone height (positive integer). Defaults to 1. + */ + segmentsHeight: number + /** + * Sets the number of cone sides (positive integer). Defaults to 36. + */ + segmentsRadial: number + /** + * Adds two extra faces per subdivision to enclose the cone around its height axis. + * Defaults to false. + */ + openEnded: boolean + /** + * Sets the radius of the top and bottom caps at once. + * + * Properties `radiusTop` and `radiusBottom` are prioritized over this one. + */ + radius: number | null + /** + * Sets the ratio (max 1) to apply to the circumference to slice the cone. Defaults to 360. + */ + arc: number +} + +/** + * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. + * A Curve3 is designed from a series of successive Vector3. + * {@link https://doc.babylonjs.com/how_to/how_to_use_curve3 } + * @public + */ +declare class Curve3 { + private _points + private _length + /** + * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. + * A Curve3 is designed from a series of successive Vector3. + * {@link http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object | Tutorial } + * @param points - points which make up the curve + */ + constructor(points: Vector3[]) + /** + * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve + * @param v0 - (Vector3) the origin point of the Quadratic Bezier + * @param v1 - (Vector3) the control point + * @param v2 - (Vector3) the end point of the Quadratic Bezier + * @param nbPoints - (integer) the wanted number of points in the curve + * @returns the created Curve3 + */ + static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3 + /** + * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve + * @param v0 - (Vector3) the origin point of the Cubic Bezier + * @param v1 - (Vector3) the first control point + * @param v2 - (Vector3) the second control point + * @param v3 - (Vector3) the end point of the Cubic Bezier + * @param nbPoints - (integer) the wanted number of points in the curve + * @returns the created Curve3 + */ + static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3 + /** + * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline + * @param p1 - (Vector3) the origin point of the Hermite Spline + * @param t1 - (Vector3) the tangent vector at the origin point + * @param p2 - (Vector3) the end point of the Hermite Spline + * @param t2 - (Vector3) the tangent vector at the end point + * @param nbPoints - (integer) the wanted number of points in the curve + * @returns the created Curve3 + */ + static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3 + /** + * Returns a Curve3 object along a CatmullRom Spline curve : + * @param points - (array of Vector3) the points the spline must pass through. At least, four points required + * @param nbPoints - (integer) the wanted number of points between each curve control points + * @param closed - (boolean) optional with default false, when true forms a closed loop from the points + * @returns the created Curve3 + */ + static CreateCatmullRomSpline(points: Vector3[], nbPoints: number, closed?: boolean): Curve3 + /** + * @returns the Curve3 stored array of successive Vector3 + */ + getPoints(): Vector3[] + /** + * @returns the computed length (float) of the curve. + */ + length(): number + /** + * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); + * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. + * curveA and curveB keep unchanged. + * @param curve - the curve to continue from this curve + * @returns the newly constructed curve + */ + continue(curve: Curve3): Curve3 + private _computeLength +} + +/** + * @public + */ +declare class CylinderShape extends Shape { + /** + * The radius of the top of the cylinder. Defaults to 0. + */ + radiusTop: number + /** + * The radius of the base of the cylinder. Defaults to 1. + */ + radiusBottom: number + /** + * Sets the number of rings along the cylinder height (positive integer). Defaults to 1. + */ + segmentsHeight: number + /** + * Sets the number of cylinder sides (positive integer). Defaults to 36. + */ + segmentsRadial: number + /** + * Adds two extra faces per subdivision to enclose the cylinder around its height axis. + * Defaults to false. + */ + openEnded: boolean + /** + * Sets the radius of the top and bottom caps at once. + * + * Properties `radiusTop` and `radiusBottom` are prioritized over this one. + */ + radius: number | null + /** + * Sets the ratio (max 1) to apply to the circumference to slice the cylinder. Defaults to 360. + */ + arc: number +} + +declare const DEG2RAD: number + +/** + * @public + */ +declare function DisposableComponent( + componentName: string, + classId: number +): >(target: TFunction) => void | TFunction + +/** + * @public + */ +declare interface DisposableComponentConstructor { + isComponent?: boolean + isDisposableComponent?: true + originalClassName?: string + new (...args: any[]): T +} + +/** + * @public + */ +declare class DisposableComponentCreated { + componentId: string + componentName: string + classId: number + constructor(componentId: string, componentName: string, classId: number) +} + +/** + * @public + */ +declare interface DisposableComponentLike extends ComponentLike { + onDispose?(): void +} + +/** + * @public + */ +declare class DisposableComponentRemoved { + componentId: string + constructor(componentId: string) +} + +/** + * @public + */ +declare class DisposableComponentUpdated { + componentId: string + component: DisposableComponentLike + constructor(componentId: string, component: DisposableComponentLike) +} + +/** + * @public + */ +declare class Engine { + readonly eventManager: EventManager + readonly rootEntity: Entity + private readonly _entities + private readonly _disposableComponents + private readonly _componentGroups + private readonly simpleSystems + readonly entities: Readonly> + readonly disposableComponents: Readonly> + constructor() + addEntity(entity: Entity): void + removeEntity(entity: Entity, removeChildren?: boolean, newParent?: Entity): void + addSystem(system: ISystem, priority?: number): void + removeSystem(system: ISystem): void + update(dt: number): void + getEntitiesWithComponent(component: string): Record + getEntitiesWithComponent(component: ComponentConstructor): Record + registerComponent(component: DisposableComponentLike): void + disposeComponent(component: DisposableComponentLike): void + updateComponent(component: DisposableComponentLike): void + getComponentGroup(...requires: ComponentConstructor[]): ComponentGroup + removeComponentGroup(componentGroup: ComponentGroup): void + private registerSystem + private checkRequirementsAndAdd + private checkRequirements + private componentAddedHandler + private componentRemovedHandler +} + +/** + * @public + */ +declare class Entity { + name?: string | undefined + children: Record + eventManager: EventManager | null + alive: boolean + readonly uuid: string + readonly components: Record + constructor(_parent?: Entity | null, name?: string | undefined) + /** + * Adds or replaces a component in the entity. + * @param component - component instance. + */ + set(component: T): void + /** + * Returns a boolean indicating if a component is present in the entity. + * @param component - component class, instance or name + */ + has(component: string): boolean + has(component: ComponentConstructor): boolean + has(component: T): boolean + /** + * Gets a component, if it doesn't exist, it throws an Error. + * @param component - component class or name + */ + get(component: string): T + get(component: ComponentConstructor): T + /** + * Gets a component, if it doesn't exist, it returns null. + * @param component - component class or name + */ + getOrNull(component: string): T | null + getOrNull(component: ComponentConstructor): T | null + /** + * Gets a component, if it doesn't exist, it creates the component and returns it. + * @param component - component class + */ + getOrCreate( + component: ComponentConstructor & { + new (): T + } + ): T + /** + * Adds a component. If the component already exist, it throws an Error. + * @param component - component instance. + */ + add(component: T): void + /** + * Removes a component instance from the entity. + * @param component - component instance to remove + * @param triggerRemovedEvent - should this action trigger an event? + */ + remove(component: string, triggerRemovedEvent?: boolean): void + remove(component: T, triggerRemovedEvent?: boolean): void + remove(component: ComponentConstructor, triggerRemovedEvent?: boolean): void + /** + * Returns true if the entity is already added to the engine. + * Returns false if no engine was defined. + */ + isAddedToEngine(): boolean + /** + * Sets the parent entity + */ + setParent(entity: Entity): void + /** + * Gets the parent entity + */ + getParent(): Entity | null + private readonly identifier + private getCircularAncestor + private registerAsChild +} + +declare const Epsilon = 0.000001 + +/** + * @public + */ +declare class EventManager { + private listeners + addListener(eventClass: IEventConstructor, listener: X, listenerFunction: (this: X, event: T) => void): void + removeListener(listener: X, eventClass: IEventConstructor): boolean + fireEvent(event: T): void +} + +declare type FloatArray = number[] + +/** + * Reprasents a camera frustum + * @beta + */ +declare class Frustum { + /** + * Gets the planes representing the frustum + * @param transform - matrix to be applied to the returned planes + * @returns a new array of 6 Frustum planes computed by the given transformation matrix. + */ + static GetPlanes(transform: Matrix): Plane[] + /** + * Gets the near frustum plane transformed by the transform matrix + * @param transform - transformation matrix to be applied to the resulting frustum plane + * @param frustumPlane - the resuling frustum plane + */ + static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void + /** + * Gets the far frustum plane transformed by the transform matrix + * @param transform - transformation matrix to be applied to the resulting frustum plane + * @param frustumPlane - the resuling frustum plane + */ + static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void + /** + * Gets the left frustum plane transformed by the transform matrix + * @param transform - transformation matrix to be applied to the resulting frustum plane + * @param frustumPlane - the resuling frustum plane + */ + static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void + /** + * Gets the right frustum plane transformed by the transform matrix + * @param transform - transformation matrix to be applied to the resulting frustum plane + * @param frustumPlane - the resuling frustum plane + */ + static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void + /** + * Gets the top frustum plane transformed by the transform matrix + * @param transform - transformation matrix to be applied to the resulting frustum plane + * @param frustumPlane - the resuling frustum plane + */ + static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void + /** + * Gets the bottom frustum plane transformed by the transform matrix + * @param transform - transformation matrix to be applied to the resulting frustum plane + * @param frustumPlane - the resuling frustum plane + */ + static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void + /** + * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix. + * @param transform - transformation matrix to be applied to the resulting frustum planes + * @param frustumPlanes - the resuling frustum planes + */ + static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void +} + +/** + * @public + */ +declare class GLTFShape extends Shape { + readonly src: string + constructor(src: string) +} + +/** + * Gizmo identifiers + * @beta + */ +declare enum Gizmo { + MOVE = 'MOVE', + ROTATE = 'ROTATE', + SCALE = 'SCALE', + NONE = 'NONE' +} + +declare type GizmoDragEndEvent = { + type: 'gizmoDragEnded' + transform: { + position: ReadOnlyVector3 + rotation: ReadOnlyQuaternion + scale: ReadOnlyVector3 + } + entityId: string +} + +declare type GizmoSelectedEvent = { + type: 'gizmoSelected' + gizmoType: 'MOVE' | 'ROTATE' | 'SCALE' + entityId: string +} + +/** + * Enables gizmos in the entity. Gizmos only work in EDITOR, PREVIEW or DEBUG modes. + * @beta + */ +declare class Gizmos extends ObservableComponent { + /** + * Enable position gizmo + */ + position: boolean + /** + * Enable rotation gizmo + */ + rotation: boolean + /** + * Enable scale gizmo + */ + scale: boolean + /** + * Cycle through gizmos using click. + */ + cycle: boolean + /** + * If cycle is false, this will be the selected gizmo + */ + selectedGizmo?: Gizmo + /** + * Align the gizmos to match the local reference system + */ + localReference: boolean +} + +/** + * @public + */ +declare interface IEventConstructor { + new (...args: any[]): T +} + +declare interface IEvents { + /** + * `positionChanged` is triggered when the position of the camera changes + * This event is throttled to 10 times per second. + */ + positionChanged: { + /** Position relative to the base parcel of the scene */ + position: ReadOnlyVector3 + /** Camera position, this is a absolute world position */ + cameraPosition: ReadOnlyVector3 + /** Eye height, in meters. */ + playerHeight: number + } + /** + * `rotationChanged` is triggered when the rotation of the camera changes. + * This event is throttled to 10 times per second. + */ + rotationChanged: { + /** {X,Y,Z} Degree vector. Same as entities */ + rotation: ReadOnlyVector3 + /** Rotation quaternion, useful in some scenarios. */ + quaternion: ReadOnlyQuaternion + } + /** + * `pointerUp` is triggered when the user releases an input pointer. + * It could be a VR controller, a touch screen or the mouse. + */ + pointerUp: PointerEvent + /** + * `pointerDown` is triggered when the user press an input pointer. + * It could be a VR controller, a touch screen or the mouse. + */ + pointerDown: PointerEvent + /** + * `chatMessage` is triggered when the user sends a message through chat entity. + */ + chatMessage: { + id: string + sender: string + message: string + isCommand: boolean + } + /** + * `onChange` is triggered when an entity changes its own internal state. + * Dispatched by the `ui-*` entities when their value is changed. It triggers a callback. + * Notice: Only entities with ID will be listening for click events. + */ + onChange: { + value?: any + /** ID of the pointer that triggered the event */ + pointerId?: number + } + /** + * `onFocus` is triggered when an entity focus is active. + * Dispatched by the `ui-input` and `ui-password` entities when the value is changed. + * It triggers a callback. + * + * Notice: Only entities with ID will be listening for click events. + */ + onFocus: { + /** ID of the entitiy of the event */ + entityId: string + /** ID of the pointer that triggered the event */ + pointerId: number + } + /** + * `onBlur` is triggered when an entity loses its focus. + * Dispatched by the `ui-input` and `ui-password` entities when the value is changed. + * It triggers a callback. + * + * Notice: Only entities with ID will be listening for click events. + */ + onBlur: { + /** ID of the entitiy of the event */ + entityId: string + /** ID of the pointer that triggered the event */ + pointerId: number + } + /** The onClick event is only used for UI elements */ + onClick: { + entityId: string + } + /** + * This event gets triggered when an entity leaves the scene fences. + */ + entityOutOfScene: { + entityId: string + } + /** + * This event gets triggered when an entity enters the scene fences. + */ + entityBackInScene: { + entityId: string + } + uuidEvent: { + uuid: string + payload: any + } + metricsUpdate: { + given: Record + limit: Record + } + limitsExceeded: { + given: Record + limit: Record + } + /** For gizmos */ + gizmoEvent: GizmoDragEndEvent | GizmoSelectedEvent +} + +/** + * Interface for the size containing width and height + * @public + */ +declare interface ISize { + /** + * Width + */ + width: number + /** + * Heighht + */ + height: number +} + +/** + * @public + */ +declare interface ISystem { + active?: boolean + activate?(engine: Engine): void + deactivate?(): void + update?(dt: number): void + onAddEntity?(entity: Entity): void + onRemoveEntity?(entity: Entity): void +} + +/** + * @public + */ +declare class Input { + private static _instance + static readonly instance: Input + readonly state: Readonly + private subscriptions + private internalState + private constructor() + static ensureInstance(): any + /** + * Subscribes to an input event and triggers the provided callback. + * + * Returns a function that can be called to remove the subscription. + * @param eventName - The name of the event (see InputEventKind). + * @param fn - A callback function to be called when the event is triggered. + */ + subscribe(eventName: InputEventKind, fn: (e: LocalPointerEvent) => void): () => void + /** + * Removes an existing input event subscription. + * @param eventName - The name of the event (see InputEventKind). + * @param fn - The callback function used when subscribing to the event. + */ + unsubscribe(eventName: InputEventKind, fn: (e: LocalPointerEvent) => void): void + private getPointerById + private handlePointerUp + private handlePointerDown +} + +declare type InputEventKind = 'BUTTON_A_DOWN' | 'BUTTON_A_UP' + +declare type InputState = Record< + Pointer, + { + BUTTON_A_DOWN: boolean + } +> + +declare type LocalPointerEvent = PointerEvent & { + origin: Vector3 + direction: Vector3 + pointer: Pointer + hit?: PointerEvent['hit'] & { + hitPoint: Vector3 + normal: Vector3 + worldNormal: Vector3 + } +} + +/** + * @public + */ +declare class Material extends ObservableComponent { + /** + * Opacity level between 0 and 1. + * Defaults to 1. + */ + alpha?: number + /** + * AKA Diffuse Color in other nomenclature. + * Defaults to #CCCCCC. + */ + albedoColor?: Color3 + /** + * The color emitted from the material. + * Defaults to black. + */ + emissiveColor?: Color3 + /** + * Specifies the metallic scalar of the metallic/roughness workflow. + * Can also be used to scale the metalness values of the metallic texture. + * Defaults to 0.5. + */ + metallic?: number + /** + * Specifies the roughness scalar of the metallic/roughness workflow. + * Can also be used to scale the roughness values of the metallic texture. + * Defaults to 0.5. + */ + roughness?: number + /** + * AKA Diffuse Color in other nomenclature. + * Defaults to black. + */ + ambientColor?: Color3 + /** + * The color reflected from the material. + * Defaults to white. + */ + reflectionColor?: Color3 + /** + * AKA Specular Color in other nomenclature. + * Defaults to white. + */ + reflectivityColor?: Color3 + /** + * Intensity of the direct lights e.g. the four lights available in scene. + * This impacts both the direct diffuse and specular highlights. + * Defaults to 1. + */ + directIntensity?: number + /** + * AKA Glossiness in other nomenclature. + * Defaults to 1. + */ + microSurface?: number + /** + * Intensity of the emissive part of the material. + * This helps controlling the emissive effect without modifying the emissive color. + * Defaults to 1. + */ + emissiveIntensity?: number + /** + * Intensity of the environment e.g. how much the environment will light the object + * either through harmonics for rough material or through the refelction for shiny ones. + * Defaults to 1. + */ + environmentIntensity?: number + /** + * This is a special control allowing the reduction of the specular highlights coming from the + * four lights of the scene. Those highlights may not be needed in full environment lighting. + * Defaults to 1. + */ + specularIntensity?: number + /** + * Texture applied as material. + */ + albedoTexture?: string + /** + * Texture applied as opacity. Default: the same texture used in albedoTexture. + */ + alphaTexture?: string + /** + * Emissive texture. + */ + emissiveTexture?: string + /** + * Stores surface normal data used to displace a mesh in a texture. + */ + bumpTexture?: string + /** + * Stores the refracted light information in a texture. + */ + refractionTexture?: string + /** + * If sets to true, disables all the lights affecting the material. + * Defaults to false. + */ + disableLighting?: boolean + /** + * Sets the transparency mode of the material. + * Defauts to 0. + * + * | Value | Type | + * | ----- | ----------------------------------- | + * | 0 | OPAQUE (default) | + * | 1 | ALPHATEST | + * | 2 | ALPHABLEND | + * | 3 | ALPHATESTANDBLEND | + */ + transparencyMode?: number + /** + * Does the albedo texture has alpha? + * Defaults to false. + */ + hasAlpha?: boolean +} + +/** + * Class used to store matrix data (4x4) + * @public + */ +declare class Matrix { + /** + * Gets the internal data of the matrix + */ + readonly m: Readonly + /** + * Gets an identity matrix that must not be updated + */ + static readonly IdentityReadOnly: Readonly + private static _updateFlagSeed + private static _identityReadOnly + /** + * Gets the update flag of the matrix which is an unique number for the matrix. + * It will be incremented every time the matrix data change. + * You can use it to speed the comparison between two versions of the same matrix. + */ + updateFlag: number + private _isIdentity + private _isIdentityDirty + private _isIdentity3x2 + private _isIdentity3x2Dirty + private readonly _m + /** + * Creates an empty matrix (filled with zeros) + */ + constructor() + /** + * Creates a matrix from an array + * @param array - defines the source array + * @param offset - defines an offset in the source array + * @returns a new Matrix set from the starting index of the given array + */ + static FromArray(array: ArrayLike, offset?: number): Matrix + /** + * Copy the content of an array into a given matrix + * @param array - defines the source array + * @param offset - defines an offset in the source array + * @param result - defines the target matrix + */ + static FromArrayToRef(array: ArrayLike, offset: number, result: Matrix): void + /** + * Stores an array into a matrix after having multiplied each component by a given factor + * @param array - defines the source array + * @param offset - defines the offset in the source array + * @param scale - defines the scaling factor + * @param result - defines the target matrix + */ + static FromFloatArrayToRefScaled(array: FloatArray, offset: number, scale: number, result: Matrix): void + /** + * Stores a list of values (16) inside a given matrix + * @param initialM11 - defines 1st value of 1st row + * @param initialM12 - defines 2nd value of 1st row + * @param initialM13 - defines 3rd value of 1st row + * @param initialM14 - defines 4th value of 1st row + * @param initialM21 - defines 1st value of 2nd row + * @param initialM22 - defines 2nd value of 2nd row + * @param initialM23 - defines 3rd value of 2nd row + * @param initialM24 - defines 4th value of 2nd row + * @param initialM31 - defines 1st value of 3rd row + * @param initialM32 - defines 2nd value of 3rd row + * @param initialM33 - defines 3rd value of 3rd row + * @param initialM34 - defines 4th value of 3rd row + * @param initialM41 - defines 1st value of 4th row + * @param initialM42 - defines 2nd value of 4th row + * @param initialM43 - defines 3rd value of 4th row + * @param initialM44 - defines 4th value of 4th row + * @param result - defines the target matrix + */ + static FromValuesToRef( + initialM11: number, + initialM12: number, + initialM13: number, + initialM14: number, + initialM21: number, + initialM22: number, + initialM23: number, + initialM24: number, + initialM31: number, + initialM32: number, + initialM33: number, + initialM34: number, + initialM41: number, + initialM42: number, + initialM43: number, + initialM44: number, + result: Matrix + ): void + /** + * Creates new matrix from a list of values (16) + * @param initialM11 - defines 1st value of 1st row + * @param initialM12 - defines 2nd value of 1st row + * @param initialM13 - defines 3rd value of 1st row + * @param initialM14 - defines 4th value of 1st row + * @param initialM21 - defines 1st value of 2nd row + * @param initialM22 - defines 2nd value of 2nd row + * @param initialM23 - defines 3rd value of 2nd row + * @param initialM24 - defines 4th value of 2nd row + * @param initialM31 - defines 1st value of 3rd row + * @param initialM32 - defines 2nd value of 3rd row + * @param initialM33 - defines 3rd value of 3rd row + * @param initialM34 - defines 4th value of 3rd row + * @param initialM41 - defines 1st value of 4th row + * @param initialM42 - defines 2nd value of 4th row + * @param initialM43 - defines 3rd value of 4th row + * @param initialM44 - defines 4th value of 4th row + * @returns the new matrix + */ + static FromValues( + initialM11: number, + initialM12: number, + initialM13: number, + initialM14: number, + initialM21: number, + initialM22: number, + initialM23: number, + initialM24: number, + initialM31: number, + initialM32: number, + initialM33: number, + initialM34: number, + initialM41: number, + initialM42: number, + initialM43: number, + initialM44: number + ): Matrix + /** + * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3) + * @param scale - defines the scale vector3 + * @param rotation - defines the rotation quaternion + * @param translation - defines the translation vector3 + * @returns a new matrix + */ + static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix + /** + * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3) + * @param scale - defines the scale vector3 + * @param rotation - defines the rotation quaternion + * @param translation - defines the translation vector3 + * @param result - defines the target matrix + */ + static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void + /** + * Creates a new identity matrix + * @returns a new identity matrix + */ + static Identity(): Matrix + /** + * Creates a new identity matrix and stores the result in a given matrix + * @param result - defines the target matrix + */ + static IdentityToRef(result: Matrix): void + /** + * Creates a new zero matrix + * @returns a new zero matrix + */ + static Zero(): Matrix + /** + * Creates a new rotation matrix for "angle" radians around the X axis + * @param angle - defines the angle (in radians) to use + * @returns the new matrix + */ + static RotationX(angle: number): Matrix + /** + * Creates a new matrix as the invert of a given matrix + * @param source - defines the source matrix + * @returns the new matrix + */ + static Invert(source: Matrix): Matrix + /** + * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix + * @param angle - defines the angle (in radians) to use + * @param result - defines the target matrix + */ + static RotationXToRef(angle: number, result: Matrix): void + /** + * Creates a new rotation matrix for "angle" radians around the Y axis + * @param angle - defines the angle (in radians) to use + * @returns the new matrix + */ + static RotationY(angle: number): Matrix + /** + * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix + * @param angle - defines the angle (in radians) to use + * @param result - defines the target matrix + */ + static RotationYToRef(angle: number, result: Matrix): void + /** + * Creates a new rotation matrix for "angle" radians around the Z axis + * @param angle - defines the angle (in radians) to use + * @returns the new matrix + */ + static RotationZ(angle: number): Matrix + /** + * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix + * @param angle - defines the angle (in radians) to use + * @param result - defines the target matrix + */ + static RotationZToRef(angle: number, result: Matrix): void + /** + * Creates a new rotation matrix for "angle" radians around the given axis + * @param axis - defines the axis to use + * @param angle - defines the angle (in radians) to use + * @returns the new matrix + */ + static RotationAxis(axis: Vector3, angle: number): Matrix + /** + * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix + * @param axis - defines the axis to use + * @param angle - defines the angle (in radians) to use + * @param result - defines the target matrix + */ + static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void + /** + * Creates a rotation matrix + * @param yaw - defines the yaw angle in radians (Y axis) + * @param pitch - defines the pitch angle in radians (X axis) + * @param roll - defines the roll angle in radians (X axis) + * @returns the new rotation matrix + */ + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix + /** + * Creates a rotation matrix and stores it in a given matrix + * @param yaw - defines the yaw angle in radians (Y axis) + * @param pitch - defines the pitch angle in radians (X axis) + * @param roll - defines the roll angle in radians (X axis) + * @param result - defines the target matrix + */ + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void + /** + * Creates a scaling matrix + * @param x - defines the scale factor on X axis + * @param y - defines the scale factor on Y axis + * @param z - defines the scale factor on Z axis + * @returns the new matrix + */ + static Scaling(x: number, y: number, z: number): Matrix + /** + * Creates a scaling matrix and stores it in a given matrix + * @param x - defines the scale factor on X axis + * @param y - defines the scale factor on Y axis + * @param z - defines the scale factor on Z axis + * @param result - defines the target matrix + */ + static ScalingToRef(x: number, y: number, z: number, result: Matrix): void + /** + * Creates a translation matrix + * @param x - defines the translation on X axis + * @param y - defines the translation on Y axis + * @param z - defines the translationon Z axis + * @returns the new matrix + */ + static Translation(x: number, y: number, z: number): Matrix + /** + * Creates a translation matrix and stores it in a given matrix + * @param x - defines the translation on X axis + * @param y - defines the translation on Y axis + * @param z - defines the translationon Z axis + * @param result - defines the target matrix + */ + static TranslationToRef(x: number, y: number, z: number, result: Matrix): void + /** + * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue". + * @param startValue - defines the start value + * @param endValue - defines the end value + * @param gradient - defines the gradient factor + * @returns the new matrix + */ + static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix + /** + * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue". + * @param startValue - defines the start value + * @param endValue - defines the end value + * @param gradient - defines the gradient factor + * @param result - defines the Matrix object where to store data + */ + static LerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void + /** + * Builds a new matrix whose values are computed by: + * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices + * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end + * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices + * @param startValue - defines the first matrix + * @param endValue - defines the second matrix + * @param gradient - defines the gradient between the two matrices + * @returns the new matrix + */ + static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix + /** + * Update a matrix to values which are computed by: + * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices + * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end + * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices + * @param startValue - defines the first matrix + * @param endValue - defines the second matrix + * @param gradient - defines the gradient between the two matrices + * @param result - defines the target matrix + */ + static DecomposeLerpToRef(startValue: Matrix, endValue: Matrix, gradient: number, result: Matrix): void + /** + * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up" + * This function works in left handed mode + * @param eye - defines the final position of the entity + * @param target - defines where the entity should look at + * @param up - defines the up vector for the entity + * @returns the new matrix + */ + static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix + /** + * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up". + * This function works in left handed mode + * @param eye - defines the final position of the entity + * @param target - defines where the entity should look at + * @param up - defines the up vector for the entity + * @param result - defines the target matrix + */ + static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void + /** + * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up" + * This function works in right handed mode + * @param eye - defines the final position of the entity + * @param target - defines where the entity should look at + * @param up - defines the up vector for the entity + * @returns the new matrix + */ + static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix + /** + * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up". + * This function works in right handed mode + * @param eye - defines the final position of the entity + * @param target - defines where the entity should look at + * @param up - defines the up vector for the entity + * @param result - defines the target matrix + */ + static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void + /** + * Create a left-handed orthographic projection matrix + * @param width - defines the viewport width + * @param height - defines the viewport height + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @returns a new matrix as a left-handed orthographic projection matrix + */ + static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix + /** + * Store a left-handed orthographic projection to a given matrix + * @param width - defines the viewport width + * @param height - defines the viewport height + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @param result - defines the target matrix + */ + static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void + /** + * Create a left-handed orthographic projection matrix + * @param left - defines the viewport left coordinate + * @param right - defines the viewport right coordinate + * @param bottom - defines the viewport bottom coordinate + * @param top - defines the viewport top coordinate + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @returns a new matrix as a left-handed orthographic projection matrix + */ + static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix + /** + * Stores a left-handed orthographic projection into a given matrix + * @param left - defines the viewport left coordinate + * @param right - defines the viewport right coordinate + * @param bottom - defines the viewport bottom coordinate + * @param top - defines the viewport top coordinate + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @param result - defines the target matrix + */ + static OrthoOffCenterLHToRef( + left: number, + right: number, + bottom: number, + top: number, + znear: number, + zfar: number, + result: Matrix + ): void + /** + * Creates a right-handed orthographic projection matrix + * @param left - defines the viewport left coordinate + * @param right - defines the viewport right coordinate + * @param bottom - defines the viewport bottom coordinate + * @param top - defines the viewport top coordinate + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @returns a new matrix as a right-handed orthographic projection matrix + */ + static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix + /** + * Stores a right-handed orthographic projection into a given matrix + * @param left - defines the viewport left coordinate + * @param right - defines the viewport right coordinate + * @param bottom - defines the viewport bottom coordinate + * @param top - defines the viewport top coordinate + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @param result - defines the target matrix + */ + static OrthoOffCenterRHToRef( + left: number, + right: number, + bottom: number, + top: number, + znear: number, + zfar: number, + result: Matrix + ): void + /** + * Creates a left-handed perspective projection matrix + * @param width - defines the viewport width + * @param height - defines the viewport height + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @returns a new matrix as a left-handed perspective projection matrix + */ + static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix + /** + * Creates a left-handed perspective projection matrix + * @param fov - defines the horizontal field of view + * @param aspect - defines the aspect ratio + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @returns a new matrix as a left-handed perspective projection matrix + */ + static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix + /** + * Stores a left-handed perspective projection into a given matrix + * @param fov - defines the horizontal field of view + * @param aspect - defines the aspect ratio + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @param result - defines the target matrix + * @param isVerticalFovFixed - defines it the fov is vertically fixed (default) or horizontally + */ + static PerspectiveFovLHToRef( + fov: number, + aspect: number, + znear: number, + zfar: number, + result: Matrix, + isVerticalFovFixed?: boolean + ): void + /** + * Creates a right-handed perspective projection matrix + * @param fov - defines the horizontal field of view + * @param aspect - defines the aspect ratio + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @returns a new matrix as a right-handed perspective projection matrix + */ + static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix + /** + * Stores a right-handed perspective projection into a given matrix + * @param fov - defines the horizontal field of view + * @param aspect - defines the aspect ratio + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @param result - defines the target matrix + * @param isVerticalFovFixed - defines it the fov is vertically fixed (default) or horizontally + */ + static PerspectiveFovRHToRef( + fov: number, + aspect: number, + znear: number, + zfar: number, + result: Matrix, + isVerticalFovFixed?: boolean + ): void + /** + * Stores a perspective projection for WebVR info a given matrix + * @param fov - defines the field of view + * @param znear - defines the near clip plane + * @param zfar - defines the far clip plane + * @param result - defines the target matrix + * @param rightHanded - defines if the matrix must be in right-handed mode (false by default) + */ + static PerspectiveFovWebVRToRef( + fov: { + upDegrees: number + downDegrees: number + leftDegrees: number + rightDegrees: number + }, + znear: number, + zfar: number, + result: Matrix, + rightHanded?: boolean + ): void + /** + * Extracts a 2x2 matrix from a given matrix and store the result in a FloatArray + * @param matrix - defines the matrix to use + * @returns a new FloatArray array with 4 elements : the 2x2 matrix extracted from the given matrix + */ + static GetAsMatrix2x2(matrix: Matrix): FloatArray + /** + * Extracts a 3x3 matrix from a given matrix and store the result in a FloatArray + * @param matrix - defines the matrix to use + * @returns a new FloatArray array with 9 elements : the 3x3 matrix extracted from the given matrix + */ + static GetAsMatrix3x3(matrix: Matrix): FloatArray + /** + * Compute the transpose of a given matrix + * @param matrix - defines the matrix to transpose + * @returns the new matrix + */ + static Transpose(matrix: Matrix): Matrix + /** + * Compute the transpose of a matrix and store it in a target matrix + * @param matrix - defines the matrix to transpose + * @param result - defines the target matrix + */ + static TransposeToRef(matrix: Matrix, result: Matrix): void + /** + * Computes a reflection matrix from a plane + * @param plane - defines the reflection plane + * @returns a new matrix + */ + static Reflection(plane: Plane): Matrix + /** + * Computes a reflection matrix from a plane + * @param plane - defines the reflection plane + * @param result - defines the target matrix + */ + static ReflectionToRef(plane: Plane, result: Matrix): void + /** + * Sets the given matrix as a rotation matrix composed from the 3 left handed axes + * @param xaxis - defines the value of the 1st axis + * @param yaxis - defines the value of the 2nd axis + * @param zaxis - defines the value of the 3rd axis + * @param result - defines the target matrix + */ + static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void + /** + * Creates a rotation matrix from a quaternion and stores it in a target matrix + * @param quat - defines the quaternion to use + * @param result - defines the target matrix + */ + static FromQuaternionToRef(quat: Quaternion, result: Matrix): void + /** + * Check if the current matrix is identity + * @returns true is the matrix is the identity matrix + */ + isIdentity(): boolean + /** + * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4) + * @returns true is the matrix is the identity matrix + */ + isIdentityAs3x2(): boolean + /** + * Gets the determinant of the matrix + * @returns the matrix determinant + */ + determinant(): number + /** + * Returns the matrix as a FloatArray + * @returns the matrix underlying array + */ + toArray(): Readonly + /** + * Returns the matrix as a FloatArray + * @returns the matrix underlying array. + */ + asArray(): Readonly + /** + * Inverts the current matrix in place + * @returns the current inverted matrix + */ + invert(): Matrix + /** + * Sets all the matrix elements to zero + * @returns the current matrix + */ + reset(): Matrix + /** + * Adds the current matrix with a second one + * @param other - defines the matrix to add + * @returns a new matrix as the addition of the current matrix and the given one + */ + add(other: Matrix): Matrix + /** + * Sets the given matrix "result" to the addition of the current matrix and the given one + * @param other - defines the matrix to add + * @param result - defines the target matrix + * @returns the current matrix + */ + addToRef(other: Matrix, result: Matrix): Matrix + /** + * Adds in place the given matrix to the current matrix + * @param other - defines the second operand + * @returns the current updated matrix + */ + addToSelf(other: Matrix): Matrix + /** + * Sets the given matrix to the current inverted Matrix + * @param other - defines the target matrix + * @returns the unmodified current matrix + */ + invertToRef(other: Matrix): Matrix + /** + * add a value at the specified position in the current Matrix + * @param index - the index of the value within the matrix. between 0 and 15. + * @param value - the value to be added + * @returns the current updated matrix + */ + addAtIndex(index: number, value: number): Matrix + /** + * mutiply the specified position in the current Matrix by a value + * @param index - the index of the value within the matrix. between 0 and 15. + * @param value - the value to be added + * @returns the current updated matrix + */ + multiplyAtIndex(index: number, value: number): Matrix + /** + * Inserts the translation vector (using 3 floats) in the current matrix + * @param x - defines the 1st component of the translation + * @param y - defines the 2nd component of the translation + * @param z - defines the 3rd component of the translation + * @returns the current updated matrix + */ + setTranslationFromFloats(x: number, y: number, z: number): Matrix + /** + * Inserts the translation vector in the current matrix + * @param vector3 - defines the translation to insert + * @returns the current updated matrix + */ + setTranslation(vector3: Vector3): Matrix + /** + * Gets the translation value of the current matrix + * @returns a new Vector3 as the extracted translation from the matrix + */ + getTranslation(): Vector3 + /** + * Fill a Vector3 with the extracted translation from the matrix + * @param result - defines the Vector3 where to store the translation + * @returns the current matrix + */ + getTranslationToRef(result: Vector3): Matrix + /** + * Remove rotation and scaling part from the matrix + * @returns the updated matrix + */ + removeRotationAndScaling(): Matrix + /** + * Multiply two matrices + * @param other - defines the second operand + * @returns a new matrix set with the multiplication result of the current Matrix and the given one + */ + multiply(other: Readonly): Matrix + /** + * Copy the current matrix from the given one + * @param other - defines the source matrix + * @returns the current updated matrix + */ + copyFrom(other: Readonly): Matrix + /** + * Populates the given array from the starting index with the current matrix values + * @param array - defines the target array + * @param offset - defines the offset in the target array where to start storing values + * @returns the current matrix + */ + copyToArray(array: FloatArray, offset?: number): Matrix + /** + * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one + * @param other - defines the second operand + * @param result - defines the matrix where to store the multiplication + * @returns the current matrix + */ + multiplyToRef(other: Readonly, result: Matrix): Matrix + /** + * Sets the FloatArray "result" from the given index "offset" with the multiplication of the current matrix and the given one + * @param other - defines the second operand + * @param result - defines the array where to store the multiplication + * @param offset - defines the offset in the target array where to start storing values + * @returns the current matrix + */ + multiplyToArray(other: Readonly, result: FloatArray, offset: number): Matrix + /** + * Check equality between this matrix and a second one + * @param value - defines the second matrix to compare + * @returns true is the current matrix and the given one values are strictly equal + */ + equals(value: Matrix): boolean + /** + * Clone the current matrix + * @returns a new matrix from the current matrix + */ + clone(): Matrix + /** + * Returns the name of the current matrix class + * @returns the string "Matrix" + */ + getClassName(): string + /** + * Gets the hash code of the current matrix + * @returns the hash code + */ + getHashCode(): number + /** + * Decomposes the current Matrix into a translation, rotation and scaling components + * @param scale - defines the scale vector3 given as a reference to update + * @param rotation - defines the rotation quaternion given as a reference to update + * @param translation - defines the translation vector3 given as a reference to update + * @returns true if operation was successful + */ + decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean + /** + * Gets specific row of the matrix + * @param index - defines the number of the row to get + * @returns the index-th row of the current matrix as a new Vector4 + */ + getRow(index: number): Nullable + /** + * Sets the index-th row of the current matrix to the vector4 values + * @param index - defines the number of the row to set + * @param row - defines the target vector4 + * @returns the updated current matrix + */ + setRow(index: number, row: Vector4): Matrix + /** + * Compute the transpose of the matrix + * @returns the new transposed matrix + */ + transpose(): Matrix + /** + * Compute the transpose of the matrix and store it in a given matrix + * @param result - defines the target matrix + * @returns the current matrix + */ + transposeToRef(result: Matrix): Matrix + /** + * Sets the index-th row of the current matrix with the given 4 x float values + * @param index - defines the row index + * @param x - defines the x component to set + * @param y - defines the y component to set + * @param z - defines the z component to set + * @param w - defines the w component to set + * @returns the updated current matrix + */ + setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix + /** + * Compute a new matrix set with the current matrix values multiplied by scale (float) + * @param scale - defines the scale factor + * @returns a new matrix + */ + scale(scale: number): Matrix + /** + * Scale the current matrix values by a factor to a given result matrix + * @param scale - defines the scale factor + * @param result - defines the matrix to store the result + * @returns the current matrix + */ + scaleToRef(scale: number, result: Matrix): Matrix + /** + * Scale the current matrix values by a factor and add the result to a given matrix + * @param scale - defines the scale factor + * @param result - defines the Matrix to store the result + * @returns the current matrix + */ + scaleAndAddToRef(scale: number, result: Matrix): Matrix + /** + * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column). + * @param ref - matrix to store the result + */ + toNormalMatrix(ref: Matrix): void + /** + * Gets only rotation part of the current matrix + * @returns a new matrix sets to the extracted rotation matrix from the current one + */ + getRotationMatrix(): Matrix + /** + * Extracts the rotation matrix from the current one and sets it as the given "result" + * @param result - defines the target matrix to store data to + * @returns the current matrix + */ + getRotationMatrixToRef(result: Matrix): Matrix + /** + * Toggles model matrix from being right handed to left handed in place and vice versa + */ + toggleModelMatrixHandInPlace(): void + /** + * Toggles projection matrix from being right handed to left handed in place and vice versa + */ + toggleProjectionMatrixHandInPlace(): void +} + +declare type Nullable = T | null + +/** + * @public + */ +declare class OBJShape extends Shape { + readonly src: string + constructor(src: string) +} + +/** + * @public + */ +declare class ObservableComponent { + dirty: boolean + data: any + private subscriptions + static field(target: ObservableComponent, propertyKey: string): void + static readonly(target: ObservableComponent, propertyKey: string): void + onChange(fn: ObservableComponentSubscription): void + toJSON(): any +} + +declare type ObservableComponentSubscription = (key: string, newVal: any, oldVal: any) => void + +/** + * @public + */ +declare class OnBlur extends OnUUIDEvent<'onBlur'> { + readonly type: string +} + +/** + * @public + */ +declare class OnChanged extends OnUUIDEvent<'onChange'> { + readonly type: string +} + +/** + * @public + */ +declare class OnClick extends OnUUIDEvent<'onClick'> { + readonly type: string +} + +/** + * @public + */ +declare class OnFocus extends OnUUIDEvent<'onFocus'> { + readonly type: string +} + +/** + * This event is triggered after the user finalizes dragging a gizmo. + * @beta + */ +declare class OnGizmoEvent extends OnUUIDEvent<'gizmoEvent'> { + readonly type: string +} + +/** + * @public + */ +declare class OnPointerDown extends PointerEventComponent {} + +/** + * @public + */ +declare class OnPointerUp extends PointerEventComponent {} + +/** + * @public + */ +declare class OnUUIDEvent extends ObservableComponent { + readonly type: string | undefined + readonly uuid: string + callback: (event: any) => void + constructor(callback: (event: IEvents[T]) => void) + toJSON(): { + uuid: string + type: string | undefined + } +} + +/** + * Defines potential orientation for back face culling + * @public + */ +declare enum Orientation { + /** + * Clockwise + */ + CW = 0, + /** Counter clockwise */ + CCW = 1 +} + +/** + * @public + */ +declare class ParentChanged { + entity: Entity + parent: Entity + constructor(entity: Entity, parent: Entity) +} + +/** + * Represents a 2D path made up of multiple 2D points + * @public + */ +declare class Path2 { + /** + * If the path start and end point are the same + */ + closed: boolean + private _points + private _length + /** + * Creates a Path2 object from the starting 2D coordinates x and y. + * @param x - the starting points x value + * @param y - the starting points y value + */ + constructor(x: number, y: number) + /** + * Creates a new path starting from an x and y position + * @param x - starting x value + * @param y - starting y value + * @returns a new Path2 starting at the coordinates (x, y). + */ + static StartingAt(x: number, y: number): Path2 + /** + * Adds a new segment until the given coordinates (x, y) to the current Path2. + * @param x - the added points x value + * @param y - the added points y value + * @returns the updated Path2. + */ + addLineTo(x: number, y: number): Path2 + /** + * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. + * @param midX - middle point x value + * @param midY - middle point y value + * @param endX - end point x value + * @param endY - end point y value + * @param numberOfSegments - (default: 36) + * @returns the updated Path2. + */ + addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2 + /** + * Closes the Path2. + * @returns the Path2. + */ + close(): Path2 + /** + * Gets the sum of the distance between each sequential point in the path + * @returns the Path2 total length (float). + */ + length(): number + /** + * Gets the points which construct the path + * @returns the Path2 internal array of points. + */ + getPoints(): Vector2[] + /** + * Retreives the point at the distance aways from the starting point + * @param normalizedLengthPosition - the length along the path to retreive the point from + * @returns a new Vector2 located at a percentage of the Path2 total length on this path. + */ + getPointAtLengthPosition(normalizedLengthPosition: number): Vector2 +} + +/** + * Represents a 3D path made up of multiple 3D points + * @public + */ +declare class Path3D { + /** + * an array of Vector3, the curve axis of the Path3D + */ + path: Vector3[] + private _curve + private _distances + private _tangents + private _normals + private _binormals + private _raw + /** + * new Path3D(path, normal, raw) + * Creates a Path3D. A Path3D is a logical math object, so not a mesh. + * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D + * @param path - an array of Vector3, the curve axis of the Path3D + * @param normal - (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. + * @param raw - (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. + */ + constructor( + /** + * an array of Vector3, the curve axis of the Path3D + */ + path: Vector3[], + firstNormal?: Nullable, + raw?: boolean + ) + /** + * Returns the Path3D array of successive Vector3 designing its curve. + * @returns the Path3D array of successive Vector3 designing its curve. + */ + getCurve(): Vector3[] + /** + * Returns an array populated with tangent vectors on each Path3D curve point. + * @returns an array populated with tangent vectors on each Path3D curve point. + */ + getTangents(): Vector3[] + /** + * Returns an array populated with normal vectors on each Path3D curve point. + * @returns an array populated with normal vectors on each Path3D curve point. + */ + getNormals(): Vector3[] + /** + * Returns an array populated with binormal vectors on each Path3D curve point. + * @returns an array populated with binormal vectors on each Path3D curve point. + */ + getBinormals(): Vector3[] + /** + * Returns an array populated with distances (float) of the i-th point from the first curve point. + * @returns an array populated with distances (float) of the i-th point from the first curve point. + */ + getDistances(): number[] + /** + * Forces the Path3D tangent, normal, binormal and distance recomputation. + * @param path - path which all values are copied into the curves points + * @param firstNormal - which should be projected onto the curve + * @returns the same object updated. + */ + update(path: Vector3[], firstNormal?: Nullable): Path3D + private _compute + private _getFirstNonNullVector + private _getLastNonNullVector + private _normalVector +} + +/** + * Represens a plane by the equation ax + by + cz + d = 0 + * @public + */ +declare class Plane { + /** + * Normal of the plane (a,b,c) + */ + normal: Vector3 + /** + * d component of the plane + */ + d: number + /** + * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0 + * @param a - a component of the plane + * @param b - b component of the plane + * @param c - c component of the plane + * @param d - d component of the plane + */ + constructor(a: number, b: number, c: number, d: number) + /** + * Creates a plane from an array + * @param array - the array to create a plane from + * @returns a new Plane from the given array. + */ + static FromArray(array: ArrayLike): Plane + /** + * Creates a plane from three points + * @param point1 - point used to create the plane + * @param point2 - point used to create the plane + * @param point3 - point used to create the plane + * @returns a new Plane defined by the three given points. + */ + static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane + /** + * Creates a plane from an origin point and a normal + * @param origin - origin of the plane to be constructed + * @param normal - normal of the plane to be constructed + * @returns a new Plane the normal vector to this plane at the given origin point. + * Note : the vector "normal" is updated because normalized. + */ + static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane + /** + * Calculates the distance from a plane and a point + * @param origin - origin of the plane to be constructed + * @param normal - normal of the plane to be constructed + * @param point - point to calculate distance to + * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point. + */ + static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number + /** + * @returns the plane coordinates as a new array of 4 elements [a, b, c, d]. + */ + asArray(): number[] + /** + * @returns a new plane copied from the current Plane. + */ + clone(): Plane + /** + * @returns the string "Plane". + */ + getClassName(): string + /** + * @returns the Plane hash code. + */ + getHashCode(): number + /** + * Normalize the current Plane in place. + * @returns the updated Plane. + */ + normalize(): Plane + /** + * Applies a transformation the plane and returns the result + * @param transformation - the transformation matrix to be applied to the plane + * @returns a new Plane as the result of the transformation of the current Plane by the given matrix. + */ + transform(transformation: Matrix): Plane + /** + * Calcualtte the dot product between the point and the plane normal + * @param point - point to calculate the dot product with + * @returns the dot product (float) of the point coordinates and the plane normal. + */ + dotCoordinate(point: Vector3): number + /** + * Updates the current Plane from the plane defined by the three given points. + * @param point1 - one of the points used to contruct the plane + * @param point2 - one of the points used to contruct the plane + * @param point3 - one of the points used to contruct the plane + * @returns the updated Plane. + */ + copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane + /** + * Checks if the plane is facing a given direction + * @param direction - the direction to check if the plane is facing + * @param epsilon - value the dot product is compared against (returns true if dot <= epsilon) + * @returns True is the vector "direction" is the same side than the plane normal. + */ + isFrontFacingTo(direction: Vector3, epsilon: number): boolean + /** + * Calculates the distance to a point + * @param point - point to calculate distance to + * @returns the signed distance (float) from the given point to the Plane. + */ + signedDistanceTo(point: Vector3): number +} + +/** + * @public + */ +declare class PlaneShape extends Shape { + /** + * Sets the horizontal length of the plane. Defaults to 1. + */ + width: number + /** + * Sets the vertical length of the plane. Defaults to 1. + */ + height: number + /** + * Sets the UV coordinates for the plane. + * Used to map specific pieces of a Material's texture into the plane's geometry. + */ + uvs: number[] +} + +/** + * @public + */ +declare enum Pointer { + PRIMARY = 'PRIMARY', + SECONDARY = 'SECONDARY' +} + +declare type PointerEvent = { + /** Origin of the ray, relative to the scene */ + origin: ReadOnlyVector3 + /** Direction vector of the ray (normalized) */ + direction: ReadOnlyVector3 + /** ID of the pointer that triggered the event */ + pointerId: number + /** Does this pointer event hit any object? */ + hit?: { + /** Length of the ray */ + length: number + /** If the ray hits a mesh the intersection point will be this */ + hitPoint: ReadOnlyVector3 + /** If the mesh has a name, it will be assigned to meshName */ + meshName: string + /** Normal of the hit */ + normal: ReadOnlyVector3 + /** Normal of the hit, in world space */ + worldNormal: ReadOnlyVector3 + /** Hit entity ID if any */ + entityId: string + } +} + +/** + * @public + */ +declare class PointerEventComponent { + readonly callback: (event: LocalPointerEvent) => void + constructor(callback: (event: LocalPointerEvent) => void) +} + +/** + * Class used to store quaternion data + * {@link https://en.wikipedia.org/wiki/Quaternion } + * {@link http://doc.babylonjs.com/features/position,_rotation,_scaling } + * @public + */ +declare class Quaternion { + /** defines the first component (0 by default) */ + x: number + /** defines the second component (0 by default) */ + y: number + /** defines the third component (0 by default) */ + z: number + /** defines the fourth component (1.0 by default) */ + w: number + /** + * Creates a new Quaternion from the given floats + * @param x - defines the first component (0 by default) + * @param y - defines the second component (0 by default) + * @param z - defines the third component (0 by default) + * @param w - defines the fourth component (1.0 by default) + */ + constructor( + /** defines the first component (0 by default) */ + x?: number, + /** defines the second component (0 by default) */ + y?: number, + /** defines the third component (0 by default) */ + z?: number, + /** defines the fourth component (1.0 by default) */ + w?: number + ) + /** + * Creates a new quaternion from a rotation matrix + * @param matrix - defines the source matrix + * @returns a new quaternion created from the given rotation matrix values + */ + static FromRotationMatrix(matrix: Matrix): Quaternion + /** + * Updates the given quaternion with the given rotation matrix values + * @param matrix - defines the source matrix + * @param result - defines the target quaternion + */ + static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void + /** + * Returns the dot product (float) between the quaternions "left" and "right" + * @param left - defines the left operand + * @param right - defines the right operand + * @returns the dot product + */ + static Dot(left: ReadOnlyQuaternion, right: ReadOnlyQuaternion): number + /** + * Checks if the two quaternions are close to each other + * @param quat0 - defines the first quaternion to check + * @param quat1 - defines the second quaternion to check + * @returns true if the two quaternions are close to each other + */ + static AreClose(quat0: ReadOnlyQuaternion, quat1: ReadOnlyQuaternion): boolean + /** + * Creates an empty quaternion + * @returns a new quaternion set to (0.0, 0.0, 0.0) + */ + static Zero(): Quaternion + /** + * Inverse a given quaternion + * @param q - defines the source quaternion + * @returns a new quaternion as the inverted current quaternion + */ + static Inverse(q: Quaternion): Quaternion + /** + * Gets a boolean indicating if the given quaternion is identity + * @param quaternion - defines the quaternion to check + * @returns true if the quaternion is identity + */ + static IsIdentity(quaternion: ReadOnlyQuaternion): boolean + /** + * Creates a quaternion from a rotation around an axis + * @param axis - defines the axis to use + * @param angle - defines the angle to use (in Euler degrees) + * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float) + */ + static RotationAxis(axis: Vector3, angle: number): Quaternion + /** + * Creates a rotation around an axis and stores it into the given quaternion + * @param axis - defines the axis to use + * @param angle - defines the angle to use (in Euler degrees) + * @param result - defines the target quaternion + * @returns the target quaternion + */ + static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion + /** + * Creates a new quaternion from data stored into an array + * @param array - defines the data source + * @param offset - defines the offset in the source array where the data starts + * @returns a new quaternion + */ + static FromArray(array: ArrayLike, offset?: number): Quaternion + /** + * Creates a new quaternion from a set of euler angles and stores it in the target quaternion + */ + static FromEulerAnglesRef(x: number, y: number, z: number, result: Quaternion): void + /** + * Creates a new quaternion from the given Euler float angles (y, x, z) + * @param yaw - defines the rotation around Y axis + * @param pitch - defines the rotation around X axis + * @param roll - defines the rotation around Z axis + * @returns the new quaternion + */ + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion + /** + * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion + * @param yaw - defines the rotation around Y axis + * @param pitch - defines the rotation around X axis + * @param roll - defines the rotation around Z axis + * @param result - defines the target quaternion + */ + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void + /** + * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation + * @param alpha - defines the rotation around first axis + * @param beta - defines the rotation around second axis + * @param gamma - defines the rotation around third axis + * @returns the new quaternion + */ + static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion + /** + * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion + * @param alpha - defines the rotation around first axis + * @param beta - defines the rotation around second axis + * @param gamma - defines the rotation around third axis + * @param result - defines the target quaternion + */ + static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void + /** + * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) + * @param axis1 - defines the first axis + * @param axis2 - defines the second axis + * @param axis3 - defines the third axis + * @returns the new quaternion + */ + static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Quaternion + /** + * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion + * @param axis1 - defines the first axis + * @param axis2 - defines the second axis + * @param axis3 - defines the third axis + * @param ref - defines the target quaternion + */ + static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void + /** + * Interpolates between two quaternions + * @param left - defines first quaternion + * @param right - defines second quaternion + * @param amount - defines the gradient to use + * @returns the new interpolated quaternion + */ + static Slerp(left: ReadOnlyQuaternion, right: ReadOnlyQuaternion, amount: number): Quaternion + /** + * Interpolates between two quaternions and stores it into a target quaternion + * @param left - defines first quaternion + * @param right - defines second quaternion + * @param amount - defines the gradient to use + * @param result - defines the target quaternion + */ + static SlerpToRef(left: ReadOnlyQuaternion, right: ReadOnlyQuaternion, amount: number, result: Quaternion): void + /** + * Interpolate between two quaternions using Hermite interpolation + * @param value1 - defines first quaternion + * @param tangent1 - defines the incoming tangent + * @param value2 - defines second quaternion + * @param tangent2 - defines the outgoing tangent + * @param amount - defines the target quaternion + * @returns the new interpolated quaternion + */ + static Hermite( + value1: ReadOnlyQuaternion, + tangent1: ReadOnlyQuaternion, + value2: ReadOnlyQuaternion, + tangent2: ReadOnlyQuaternion, + amount: number + ): Quaternion + /** + * Creates an identity quaternion + * @returns - the identity quaternion + */ + static readonly Identity: Quaternion + /** + * Returns the angle in degrees between two rotations a and b. + * @param quat1 - defines the first quaternion + * @param quat2 - defines the second quaternion + */ + static Angle(quat1: ReadOnlyQuaternion, quat2: ReadOnlyQuaternion): number + /** + * Returns a rotation that rotates z degrees around the z axis, x degrees around the x axis, and y degrees around the y axis. + * @param x - the rotation on the x axis in euler degrees + * @param y - the rotation on the y axis in euler degrees + * @param z - the rotation on the z axis in euler degrees + */ + static Euler(x: number, y: number, z: number): Quaternion + /** + * Creates a rotation with the specified forward and upwards directions. + * @param forward - the direction to look in + * @param up - the vector that defines in which direction up is + */ + static LookRotation(forward: Vector3, up?: Vector3): Quaternion + /** + * The from quaternion is rotated towards to by an angular step of maxDegreesDelta. + * @param from - defines the first quaternion + * @param to - defines the second quaternion + * @param maxDegreesDelta - the interval step + */ + static RotateTowards(from: ReadOnlyQuaternion, to: Quaternion, maxDegreesDelta: number): Quaternion + /** + * Creates a rotation which rotates from fromDirection to toDirection. + * @param from - defines the first Vector + * @param to - defines the second Vector + */ + static FromToRotation(from: Vector3, to: Vector3): Quaternion + /** + * Converts this quaternion to one with the same orientation but with a magnitude of 1. + */ + readonly normalized: Quaternion + /** + * Creates a rotation which rotates from fromDirection to toDirection. + * @param from - defines the first Vector + * @param to - defines the second Vector + * @param up - defines the direction + */ + setFromToRotation(from: Vector3, to: Vector3, up?: Vector3): void + /** + * Gets the euler angle representation of the rotation. + */ + /** + * Sets the euler angle representation of the rotation. + */ + eulerAngles: Vector3 + /** + * Gets a string representation for the current quaternion + * @returns a string with the Quaternion coordinates + */ + toString(): string + /** + * Gets length of current quaternion + * @returns the quaternion length (float) + */ + readonly length: number + /** + * Gets length of current quaternion + * @returns the quaternion length (float) + */ + readonly lengthSquared: number + /** + * Gets the class name of the quaternion + * @returns the string "Quaternion" + */ + getClassName(): string + /** + * Gets a hash code for this quaternion + * @returns the quaternion hash code + */ + getHashCode(): number + /** + * Copy the quaternion to an array + * @returns a new array populated with 4 elements from the quaternion coordinates + */ + asArray(): number[] + /** + * Check if two quaternions are equals + * @param otherQuaternion - defines the second operand + * @returns true if the current quaternion and the given one coordinates are strictly equals + */ + equals(otherQuaternion: ReadOnlyQuaternion): boolean + /** + * Clone the current quaternion + * @returns a new quaternion copied from the current one + */ + clone(): Quaternion + /** + * Copy a quaternion to the current one + * @param other - defines the other quaternion + * @returns the updated current quaternion + */ + copyFrom(other: ReadOnlyQuaternion): Quaternion + /** + * Updates the current quaternion with the given float coordinates + * @param x - defines the x coordinate + * @param y - defines the y coordinate + * @param z - defines the z coordinate + * @param w - defines the w coordinate + * @returns the updated current quaternion + */ + copyFromFloats(x: number, y: number, z: number, w: number): Quaternion + /** + * Updates the current quaternion from the given float coordinates + * @param x - defines the x coordinate + * @param y - defines the y coordinate + * @param z - defines the z coordinate + * @param w - defines the w coordinate + * @returns the updated current quaternion + */ + set(x: number, y: number, z: number, w: number): Quaternion + /** + * Updates the current quaternion from the given euler angles + * @returns the updated current quaternion + */ + setEuler(x: number, y: number, z: number): Quaternion + /** + * Subtract two quaternions + * @param other - defines the second operand + * @returns a new quaternion as the subtraction result of the given one from the current one + */ + subtract(other: Quaternion): Quaternion + /** + * Multiplies the current quaternion by a scale factor + * @param value - defines the scale factor + * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale" + */ + scale(value: number): Quaternion + /** + * Scale the current quaternion values by a factor and stores the result to a given quaternion + * @param scale - defines the scale factor + * @param result - defines the Quaternion object where to store the result + * @returns the unmodified current quaternion + */ + scaleToRef(scale: number, result: Quaternion): Quaternion + /** + * Multiplies in place the current quaternion by a scale factor + * @param value - defines the scale factor + * @returns the current modified quaternion + */ + scaleInPlace(value: number): Quaternion + /** + * Scale the current quaternion values by a factor and add the result to a given quaternion + * @param scale - defines the scale factor + * @param result - defines the Quaternion object where to store the result + * @returns the unmodified current quaternion + */ + scaleAndAddToRef(scale: number, result: Quaternion): Quaternion + /** + * Multiplies two quaternions + * @param q1 - defines the second operand + * @returns a new quaternion set as the multiplication result of the current one with the given one "q1" + */ + multiply(q1: ReadOnlyQuaternion): Quaternion + /** + * Sets the given "result" as the the multiplication result of the current one with the given one "q1" + * @param q1 - defines the second operand + * @param result - defines the target quaternion + * @returns the current quaternion + */ + multiplyToRef(q1: ReadOnlyQuaternion, result: Quaternion): Quaternion + /** + * Updates the current quaternion with the multiplication of itself with the given one "q1" + * @param q1 - defines the second operand + * @returns the currentupdated quaternion + */ + multiplyInPlace(q1: ReadOnlyQuaternion): Quaternion + /** + * Conjugates (1-q) the current quaternion and stores the result in the given quaternion + * @param ref - defines the target quaternion + * @returns the current quaternion + */ + conjugateToRef(ref: Quaternion): Quaternion + /** + * Conjugates in place (1-q) the current quaternion + * @returns the current updated quaternion + */ + conjugateInPlace(): Quaternion + /** + * Conjugates in place (1-q) the current quaternion + * @returns a new quaternion + */ + conjugate(): Quaternion + /** + * Normalize in place the current quaternion + * @returns the current updated quaternion + */ + normalize(): Quaternion + angleAxis(degress: number, axis: Vector3): Quaternion + /** + * Updates the given rotation matrix with the current quaternion values + * @param result - defines the target matrix + * @returns the current unchanged quaternion + */ + toRotationMatrix(result: Matrix): Quaternion + /** + * Updates the current quaternion from the given rotation matrix values + * @param matrix - defines the source matrix + * @returns the current updated quaternion + */ + fromRotationMatrix(matrix: Matrix): Quaternion +} + +declare const RAD2DEG: number + +declare type ReadOnlyQuaternion = { + readonly x: number + readonly y: number + readonly z: number + readonly w: number +} + +declare type ReadOnlyVector2 = { + readonly x: number + readonly y: number +} + +declare type ReadOnlyVector3 = { + readonly y: number + readonly x: number + readonly z: number +} + +declare type ReadOnlyVector4 = { + readonly y: number + readonly x: number + readonly z: number + readonly w: number +} + +/** + * Scalar computation library + * @public + */ +declare class Scalar { + /** + * Two pi constants convenient for computation. + */ + static TwoPi: number + /** + * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) + * @param a - number + * @param b - number + * @param epsilon - (default = 1.401298E-45) + * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) + */ + static WithinEpsilon(a: number, b: number, epsilon?: number): boolean + /** + * Returns a string : the upper case translation of the number i to hexadecimal. + * @param i - number + * @returns the upper case translation of the number i to hexadecimal. + */ + static ToHex(i: number): string + /** + * Returns -1 if value is negative and +1 is value is positive. + * @param _value - the value + * @returns the value itself if it's equal to zero. + */ + static Sign(value: number): number + /** + * Returns the value itself if it's between min and max. + * Returns min if the value is lower than min. + * Returns max if the value is greater than max. + * @param value - the value to clmap + * @param min - the min value to clamp to (default: 0) + * @param max - the max value to clamp to (default: 1) + * @returns the clamped value + */ + static Clamp(value: number, min?: number, max?: number): number + /** + * the log2 of value. + * @param value - the value to compute log2 of + * @returns the log2 of value. + */ + static Log2(value: number): number + /** + * Loops the value, so that it is never larger than length and never smaller than 0. + * + * This is similar to the modulo operator but it works with floating point numbers. + * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. + * With t = 5 and length = 2.5, the result would be 0.0. + * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator + * @param value - the value + * @param length - the length + * @returns the looped value + */ + static Repeat(value: number, length: number): number + /** + * Normalize the value between 0.0 and 1.0 using min and max values + * @param value - value to normalize + * @param min - max to normalize between + * @param max - min to normalize between + * @returns the normalized value + */ + static Normalize(value: number, min: number, max: number): number + /** + * Denormalize the value from 0.0 and 1.0 using min and max values + * @param normalized - value to denormalize + * @param min - max to denormalize between + * @param max - min to denormalize between + * @returns the denormalized value + */ + static Denormalize(normalized: number, min: number, max: number): number + /** + * Calculates the shortest difference between two given angles given in degrees. + * @param current - current angle in degrees + * @param target - target angle in degrees + * @returns the delta + */ + static DeltaAngle(current: number, target: number): number + /** + * PingPongs the value t, so that it is never larger than length and never smaller than 0. + * @param tx - value + * @param length - length + * @returns The returned value will move back and forth between 0 and length + */ + static PingPong(tx: number, length: number): number + /** + * Interpolates between min and max with smoothing at the limits. + * + * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up + * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. + * @param from - from + * @param to - to + * @param tx - value + * @returns the smooth stepped value + */ + static SmoothStep(from: number, to: number, tx: number): number + /** + * Moves a value current towards target. + * + * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. + * Negative values of maxDelta pushes the value away from target. + * @param current - current value + * @param target - target value + * @param maxDelta - max distance to move + * @returns resulting value + */ + static MoveTowards(current: number, target: number, maxDelta: number): number + /** + * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. + * + * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta + * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. + * @param current - current value + * @param target - target value + * @param maxDelta - max distance to move + * @returns resulting angle + */ + static MoveTowardsAngle(current: number, target: number, maxDelta: number): number + /** + * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. + * @param start - start value + * @param end - target value + * @param amount - amount to lerp between + * @returns the lerped value + */ + static Lerp(start: number, end: number, amount: number): number + /** + * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. + * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. + * @param start - start value + * @param end - target value + * @param amount - amount to lerp between + * @returns the lerped value + */ + static LerpAngle(start: number, end: number, amount: number): number + /** + * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. + * @param a - start value + * @param b - target value + * @param value - value between a and b + * @returns the inverseLerp value + */ + static InverseLerp(a: number, b: number, value: number): number + /** + * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". + * {@link http://mathworld.wolfram.com/HermitePolynomial.html} + * @param value1 - spline value + * @param tangent1 - spline value + * @param value2 - spline value + * @param tangent2 - spline value + * @param amount - input value + * @returns hermite result + */ + static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number + /** + * Returns a random float number between and min and max values + * @param min - min value of random + * @param max - max value of random + * @returns random value + */ + static RandomRange(min: number, max: number): number + /** + * This function returns percentage of a number in a given range. + * + * RangeToPercent(40,20,60) will return 0.5 (50%) + * RangeToPercent(34,0,100) will return 0.34 (34%) + * @param num - to convert to percentage + * @param min - min range + * @param max - max range + * @returns the percentage + */ + static RangeToPercent(num: number, min: number, max: number): number + /** + * This function returns number that corresponds to the percentage in a given range. + * + * PercentToRange(0.34,0,100) will return 34. + * @param percent - to convert to number + * @param min - min range + * @param max - max range + * @returns the number + */ + static PercentToRange(percent: number, min: number, max: number): number + /** + * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians. + * @param angle - The angle to normalize in radian. + * @returns The converted angle. + */ + static NormalizeRadians(angle: number): number +} + +/** + * @public + */ +declare class Shape extends ObservableComponent { + /** + * Set to true to turn on the collider for the entity. + * @alpha + */ + withCollisions: boolean + /** + * Defines if the entity and its children should be rendered + * @alpha + */ + visible: boolean +} + +/** + * Size containing widht and height + * @public + */ +declare class Size implements ISize { + /** + * The surface of the Size : width * height (float). + */ + readonly surface: number + /** + * Width + */ + width: number + /** + * Height + */ + height: number + /** + * Creates a Size object from the given width and height (floats). + * @param width - width of the new size + * @param height - height of the new size + */ + constructor(width: number, height: number) + /** + * Create a new size of zero + * @returns a new Size set to (0.0, 0.0) + */ + static Zero(): Size + /** + * Creates a new Size set at the linear interpolation "amount" between "start" and "end" + * @param start - starting size to lerp between + * @param end - end size to lerp between + * @param amount - amount to lerp between the start and end values + * @returns a new Size set at the linear interpolation "amount" between "start" and "end" + */ + static Lerp(start: Size, end: Size, amount: number): Size + /** + * Returns a string with the Size width and height + * @returns a string with the Size width and height + */ + toString(): string + /** + * "Size" + * @returns the string "Size" + */ + getClassName(): string + /** + * Returns the Size hash code. + * @returns a hash code for a unique width and height + */ + getHashCode(): number + /** + * Updates the current size from the given one. + * @param src - the given size + */ + copyFrom(src: Size): void + /** + * Updates in place the current Size from the given floats. + * @param width - width of the new size + * @param height - height of the new size + * @returns the updated Size. + */ + copyFromFloats(width: number, height: number): Size + /** + * Updates in place the current Size from the given floats. + * @param width - width to set + * @param height - height to set + * @returns the updated Size. + */ + set(width: number, height: number): Size + /** + * Multiplies the width and height by numbers + * @param w - factor to multiple the width by + * @param h - factor to multiple the height by + * @returns a new Size set with the multiplication result of the current Size and the given floats. + */ + multiplyByFloats(w: number, h: number): Size + /** + * Clones the size + * @returns a new Size copied from the given one. + */ + clone(): Size + /** + * True if the current Size and the given one width and height are strictly equal. + * @param other - the other size to compare against + * @returns True if the current Size and the given one width and height are strictly equal. + */ + equals(other: Size): boolean + /** + * Sums the width and height of two sizes + * @param otherSize - size to add to this size + * @returns a new Size set as the addition result of the current Size and the given one. + */ + add(otherSize: Size): Size + /** + * Subtracts the width and height of two + * @param otherSize - size to subtract to this size + * @returns a new Size set as the subtraction result of the given one from the current Size. + */ + subtract(otherSize: Size): Size +} + +/** + * Defines supported spaces + * @public + */ +declare enum Space { + /** Local (object) space */ + LOCAL = 0, + /** World space */ + WORLD = 1, + /** Bone space */ + BONE = 2 +} + +/** + * @public + */ +declare class SphereShape extends Shape {} + +declare type TaskResult = Promise & { + isComplete: boolean + didFail?: boolean + error?: Error + result?: T +} + +/** + * @public + */ +declare class TextShape extends Shape { + outlineWidth: number + outlineColor: Color3 + color: Color3 + fontFamily: string + fontSize: number + fontWeight: string + opacity: number + value: string + lineSpacing: string + lineCount: number + resizeToFit: boolean + textWrapping: boolean + shadowBlur: number + shadowOffsetX: number + shadowOffsetY: number + shadowColor: Color3 + zIndex: number + hAlign: string + vAlign: string + width: number + height: number + paddingTop: number + paddingRight: number + paddingBottom: number + paddingLeft: number + isPickable: boolean + billboard: boolean + constructor(value?: string) +} + +declare const ToGammaSpace: number + +declare const ToLinearSpace = 2.2 + +declare type TranformConstructorArgs = { + position?: Vector3 + rotation?: Quaternion + scale?: Vector3 +} + +/** + * @public + */ +declare class Transform extends ObservableComponent { + position: Vector3 + rotation: Quaternion + scale: Vector3 + constructor(args?: TranformConstructorArgs) + /** + * @public + * The rotation as Euler angles in degrees. + */ + readonly eulerAngles: Vector3 + /** + * @public + * Rotates the transform so the forward vector points at target's current position. + */ + lookAt(target: Vector3, worldUp?: Vector3): void + /** + * @public + * Applies a rotation of euler angles around the x, y and z axis. + */ + rotate(axis: Vector3, angle: number): void + /** + * @public + * Moves the transform in the direction and distance of translation. + */ + translate(vec: Vector3): void +} + +/** + * @public + */ +declare class UUIDEvent { + uuid: string + payload: T +} + +/** + * @public + */ +declare class UUIDEventSystem implements ISystem { + handlerMap: { + [uuid: string]: OnUUIDEvent + } + activate(engine: Engine): void + deactivate(): void + onAddEntity(entity: Entity): void + onRemoveEntity(entity: Entity): void + private componentAdded + private componentRemoved + private handleEvent +} + +/** + * Class representing a vector containing 2 coordinates + * @public + */ +declare class Vector2 { + /** defines the first coordinate */ + x: number + /** defines the second coordinate */ + y: number + /** + * Creates a new Vector2 from the given x and y coordinates + * @param x - defines the first coordinate + * @param y - defines the second coordinate + */ + constructor( + /** defines the first coordinate */ + x?: number, + /** defines the second coordinate */ + y?: number + ) + /** + * Gets a new Vector2(0, 0) + * @returns a new Vector2 + */ + static Zero(): Vector2 + /** + * Gets a new Vector2(1, 1) + * @returns a new Vector2 + */ + static One(): Vector2 + /** + * Returns a new Vector2 as the result of the addition of the two given vectors. + * @param vector1 - the first vector + * @param vector2 - the second vector + * @returns the resulting vector + */ + static Add(vector1: ReadOnlyVector2, vector2: ReadOnlyVector2): Vector2 + /** + * Gets a new Vector2 set from the given index element of the given array + * @param array - defines the data source + * @param offset - defines the offset in the data source + * @returns a new Vector2 + */ + static FromArray(array: ArrayLike, offset?: number): Vector2 + /** + * Sets "result" from the given index element of the given array + * @param array - defines the data source + * @param offset - defines the offset in the data source + * @param result - defines the target vector + */ + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector2): void + /** + * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2 + * @param value1 - defines 1st point of control + * @param value2 - defines 2nd point of control + * @param value3 - defines 3rd point of control + * @param value4 - defines 4th point of control + * @param amount - defines the interpolation factor + * @returns a new Vector2 + */ + static CatmullRom( + value1: ReadOnlyVector2, + value2: ReadOnlyVector2, + value3: ReadOnlyVector2, + value4: ReadOnlyVector2, + amount: number + ): Vector2 + /** + * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". + * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. + * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate + * @param value - defines the value to clamp + * @param min - defines the lower limit + * @param max - defines the upper limit + * @returns a new Vector2 + */ + static Clamp(value: ReadOnlyVector2, min: ReadOnlyVector2, max: ReadOnlyVector2): Vector2 + /** + * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2" + * @param value1 - defines the 1st control point + * @param tangent1 - defines the outgoing tangent + * @param value2 - defines the 2nd control point + * @param tangent2 - defines the incoming tangent + * @param amount - defines the interpolation factor + * @returns a new Vector2 + */ + static Hermite( + value1: ReadOnlyVector2, + tangent1: ReadOnlyVector2, + value2: ReadOnlyVector2, + tangent2: ReadOnlyVector2, + amount: number + ): Vector2 + /** + * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". + * @param start - defines the start vector + * @param end - defines the end vector + * @param amount - defines the interpolation factor + * @returns a new Vector2 + */ + static Lerp(start: ReadOnlyVector2, end: ReadOnlyVector2, amount: number): Vector2 + /** + * Gets the dot product of the vector "left" and the vector "right" + * @param left - defines first vector + * @param right - defines second vector + * @returns the dot product (float) + */ + static Dot(left: ReadOnlyVector2, right: ReadOnlyVector2): number + /** + * Returns a new Vector2 equal to the normalized given vector + * @param vector - defines the vector to normalize + * @returns a new Vector2 + */ + static Normalize(vector: ReadOnlyVector2): Vector2 + /** + * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors + * @param left - defines 1st vector + * @param right - defines 2nd vector + * @returns a new Vector2 + */ + static Minimize(left: ReadOnlyVector2, right: ReadOnlyVector2): Vector2 + /** + * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors + * @param left - defines 1st vector + * @param right - defines 2nd vector + * @returns a new Vector2 + */ + static Maximize(left: ReadOnlyVector2, right: ReadOnlyVector2): Vector2 + /** + * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix + * @param vector - defines the vector to transform + * @param transformation - defines the matrix to apply + * @returns a new Vector2 + */ + static Transform(vector: Vector2, transformation: Matrix): Vector2 + /** + * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates + * @param vector - defines the vector to transform + * @param transformation - defines the matrix to apply + * @param result - defines the target vector + */ + static TransformToRef(vector: ReadOnlyVector2, transformation: Matrix, result: Vector2): void + /** + * Determines if a given vector is included in a triangle + * @param p - defines the vector to test + * @param p0 - defines 1st triangle point + * @param p1 - defines 2nd triangle point + * @param p2 - defines 3rd triangle point + * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" + */ + static PointInTriangle(p: ReadOnlyVector2, p0: ReadOnlyVector2, p1: ReadOnlyVector2, p2: ReadOnlyVector2): boolean + /** + * Gets the distance between the vectors "value1" and "value2" + * @param value1 - defines first vector + * @param value2 - defines second vector + * @returns the distance between vectors + */ + static Distance(value1: Vector2, value2: Vector2): number + /** + * Returns the squared distance between the vectors "value1" and "value2" + * @param value1 - defines first vector + * @param value2 - defines second vector + * @returns the squared distance between vectors + */ + static DistanceSquared(value1: ReadOnlyVector2, value2: ReadOnlyVector2): number + /** + * Gets a new Vector2 located at the center of the vectors "value1" and "value2" + * @param value1 - defines first vector + * @param value2 - defines second vector + * @returns a new Vector2 + */ + static Center(value1: ReadOnlyVector2, value2: ReadOnlyVector2): Vector2 + /** + * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". + * @param p - defines the middle point + * @param segA - defines one point of the segment + * @param segB - defines the other point of the segment + * @returns the shortest distance + */ + static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number + /** + * Gets a string with the Vector2 coordinates + * @returns a string with the Vector2 coordinates + */ + toString(): string + /** + * Gets class name + * @returns the string "Vector2" + */ + getClassName(): string + /** + * Gets current vector hash code + * @returns the Vector2 hash code as a number + */ + getHashCode(): number + /** + * Sets the Vector2 coordinates in the given array or FloatArray from the given index. + * @param array - defines the source array + * @param index - defines the offset in source array + * @returns the current Vector2 + */ + toArray(array: FloatArray, index?: number): Vector2 + /** + * Copy the current vector to an array + * @returns a new array with 2 elements: the Vector2 coordinates. + */ + asArray(): number[] + /** + * Sets the Vector2 coordinates with the given Vector2 coordinates + * @param source - defines the source Vector2 + * @returns the current updated Vector2 + */ + copyFrom(source: ReadOnlyVector2): Vector2 + /** + * Sets the Vector2 coordinates with the given floats + * @param x - defines the first coordinate + * @param y - defines the second coordinate + * @returns the current updated Vector2 + */ + copyFromFloats(x: number, y: number): Vector2 + /** + * Sets the Vector2 coordinates with the given floats + * @param x - defines the first coordinate + * @param y - defines the second coordinate + * @returns the current updated Vector2 + */ + set(x: number, y: number): Vector2 + /** + * Add another vector with the current one + * @param otherVector - defines the other vector + * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates + */ + add(otherVector: ReadOnlyVector2): Vector2 + /** + * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates + * @param otherVector - defines the other vector + * @param result - defines the target vector + * @returns the unmodified current Vector2 + */ + addToRef(otherVector: ReadOnlyVector2, result: Vector2): Vector2 + /** + * Set the Vector2 coordinates by adding the given Vector2 coordinates + * @param otherVector - defines the other vector + * @returns the current updated Vector2 + */ + addInPlace(otherVector: ReadOnlyVector2): Vector2 + /** + * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates + * @param otherVector - defines the other vector + * @returns a new Vector2 + */ + addVector3(otherVector: ReadOnlyVector2): Vector2 + /** + * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2 + * @param otherVector - defines the other vector + * @returns a new Vector2 + */ + subtract(otherVector: ReadOnlyVector2): Vector2 + /** + * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates. + * @param otherVector - defines the other vector + * @param result - defines the target vector + * @returns the unmodified current Vector2 + */ + subtractToRef(otherVector: ReadOnlyVector2, result: Vector2): Vector2 + /** + * Sets the current Vector2 coordinates by subtracting from it the given one coordinates + * @param otherVector - defines the other vector + * @returns the current updated Vector2 + */ + subtractInPlace(otherVector: ReadOnlyVector2): Vector2 + /** + * Multiplies in place the current Vector2 coordinates by the given ones + * @param otherVector - defines the other vector + * @returns the current updated Vector2 + */ + multiplyInPlace(otherVector: ReadOnlyVector2): Vector2 + /** + * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates + * @param otherVector - defines the other vector + * @returns a new Vector2 + */ + multiply(otherVector: ReadOnlyVector2): Vector2 + /** + * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates + * @param otherVector - defines the other vector + * @param result - defines the target vector + * @returns the unmodified current Vector2 + */ + multiplyToRef(otherVector: ReadOnlyVector2, result: Vector2): Vector2 + /** + * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats + * @param x - defines the first coordinate + * @param y - defines the second coordinate + * @returns a new Vector2 + */ + multiplyByFloats(x: number, y: number): Vector2 + /** + * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates + * @param otherVector - defines the other vector + * @returns a new Vector2 + */ + divide(otherVector: ReadOnlyVector2): Vector2 + /** + * Sets the "result" coordinates with the Vector2 divided by the given one coordinates + * @param otherVector - defines the other vector + * @param result - defines the target vector + * @returns the unmodified current Vector2 + */ + divideToRef(otherVector: ReadOnlyVector2, result: Vector2): Vector2 + /** + * Divides the current Vector2 coordinates by the given ones + * @param otherVector - defines the other vector + * @returns the current updated Vector2 + */ + divideInPlace(otherVector: ReadOnlyVector2): Vector2 + /** + * Gets a new Vector2 with current Vector2 negated coordinates + * @returns a new Vector2 + */ + negate(): Vector2 + /** + * Multiply the Vector2 coordinates by scale + * @param scale - defines the scaling factor + * @returns the current updated Vector2 + */ + scaleInPlace(scale: number): Vector2 + /** + * Returns a new Vector2 scaled by "scale" from the current Vector2 + * @param scale - defines the scaling factor + * @returns a new Vector2 + */ + scale(scale: number): Vector2 + /** + * Scale the current Vector2 values by a factor to a given Vector2 + * @param scale - defines the scale factor + * @param result - defines the Vector2 object where to store the result + * @returns the unmodified current Vector2 + */ + scaleToRef(scale: number, result: Vector2): Vector2 + /** + * Scale the current Vector2 values by a factor and add the result to a given Vector2 + * @param scale - defines the scale factor + * @param result - defines the Vector2 object where to store the result + * @returns the unmodified current Vector2 + */ + scaleAndAddToRef(scale: number, result: Vector2): Vector2 + /** + * Gets a boolean if two vectors are equals + * @param otherVector - defines the other vector + * @returns true if the given vector coordinates strictly equal the current Vector2 ones + */ + equals(otherVector: ReadOnlyVector2): boolean + /** + * Gets a boolean if two vectors are equals (using an epsilon value) + * @param otherVector - defines the other vector + * @param epsilon - defines the minimal distance to consider equality + * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon. + */ + equalsWithEpsilon(otherVector: ReadOnlyVector2, epsilon?: number): boolean + /** + * Gets a new Vector2 from current Vector2 floored values + * @returns a new Vector2 + */ + floor(): Vector2 + /** + * Gets a new Vector2 from current Vector2 floored values + * @returns a new Vector2 + */ + fract(): Vector2 + /** + * Gets the length of the vector + * @returns the vector length (float) + */ + length(): number + /** + * Gets the vector squared length + * @returns the vector squared length (float) + */ + lengthSquared(): number + /** + * Normalize the vector + * @returns the current updated Vector2 + */ + normalize(): Vector2 + /** + * Gets a new Vector2 copied from the Vector2 + * @returns a new Vector2 + */ + clone(): Vector2 +} + +/** + * Classed used to store (x,y,z) vector representation + * A Vector3 is the main object used in 3D geometry + * It can represent etiher the coordinates of a point the space, either a direction + * Reminder: Babylon.js uses a left handed forward facing system + * @public + */ +declare class Vector3 { + /** + * Defines the first coordinates (on X axis) + */ + x: number + /** + * Defines the second coordinates (on Y axis) + */ + y: number + /** + * Defines the third coordinates (on Z axis) + */ + z: number + /** + * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same + */ + readonly isNonUniform: boolean + /** + * Creates a new Vector3 object from the given x, y, z (floats) coordinates. + * @param x - defines the first coordinates (on X axis) + * @param y - defines the second coordinates (on Y axis) + * @param z - defines the third coordinates (on Z axis) + */ + constructor( + /** + * Defines the first coordinates (on X axis) + */ + x?: number, + /** + * Defines the second coordinates (on Y axis) + */ + y?: number, + /** + * Defines the third coordinates (on Z axis) + */ + z?: number + ) + /** + * Returns a new Vector3 as the result of the addition of the two given vectors. + * @param vector1 - the first vector + * @param vector2 - the second vector + * @returns the resulting vector + */ + static Add(vector1: ReadOnlyVector3, vector2: ReadOnlyVector3): Vector3 + /** + * Get the clip factor between two vectors + * @param vector0 - defines the first operand + * @param vector1 - defines the second operand + * @param axis - defines the axis to use + * @param size - defines the size along the axis + * @returns the clip factor + */ + static GetClipFactor(vector0: ReadOnlyVector3, vector1: ReadOnlyVector3, axis: ReadOnlyVector3, size: number): number + /** + * Get angle between two vectors + * @param vector0 - angle between vector0 and vector1 + * @param vector1 - angle between vector0 and vector1 + * @param normal - direction of the normal + * @returns the angle between vector0 and vector1 + */ + static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: ReadOnlyVector3): number + /** + * Returns a new Vector3 set from the index "offset" of the given array + * @param array - defines the source array + * @param offset - defines the offset in the source array + * @returns the new Vector3 + */ + static FromArray(array: ArrayLike, offset?: number): Vector3 + /** + * Returns a new Vector3 set from the index "offset" of the given FloatArray + * This function is deprecated. Use FromArray instead + * @param array - defines the source array + * @param offset - defines the offset in the source array + * @returns the new Vector3 + */ + static FromFloatArray(array: FloatArray, offset?: number): Vector3 + /** + * Sets the given vector "result" with the element values from the index "offset" of the given array + * @param array - defines the source array + * @param offset - defines the offset in the source array + * @param result - defines the Vector3 where to store the result + */ + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector3): void + /** + * Sets the given vector "result" with the element values from the index "offset" of the given FloatArray + * This function is deprecated. Use FromArrayToRef instead. + * @param array - defines the source array + * @param offset - defines the offset in the source array + * @param result - defines the Vector3 where to store the result + */ + static FromFloatArrayToRef(array: FloatArray, offset: number, result: Vector3): void + /** + * Sets the given vector "result" with the given floats. + * @param x - defines the x coordinate of the source + * @param y - defines the y coordinate of the source + * @param z - defines the z coordinate of the source + * @param result - defines the Vector3 where to store the result + */ + static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void + /** + * Returns a new Vector3 set to (0.0, 0.0, 0.0) + * @returns a new empty Vector3 + */ + static Zero(): Vector3 + /** + * Returns a new Vector3 set to (1.0, 1.0, 1.0) + * @returns a new unit Vector3 + */ + static One(): Vector3 + /** + * Returns a new Vector3 set to (0.0, 1.0, 0.0) + * @returns a new up Vector3 + */ + static Up(): Vector3 + /** + * Returns a new Vector3 set to (0.0, -1.0, 0.0) + * @returns a new down Vector3 + */ + static Down(): Vector3 + /** + * Returns a new Vector3 set to (0.0, 0.0, 1.0) + * @returns a new forward Vector3 + */ + static Forward(): Vector3 + /** + * Returns a new Vector3 set to (0.0, 0.0, -1.0) + * @returns a new forward Vector3 + */ + static Backward(): Vector3 + /** + * Returns a new Vector3 set to (1.0, 0.0, 0.0) + * @returns a new right Vector3 + */ + static Right(): Vector3 + /** + * Returns a new Vector3 set to (-1.0, 0.0, 0.0) + * @returns a new left Vector3 + */ + static Left(): Vector3 + /** + * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector. + * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) + * @param vector - defines the Vector3 to transform + * @param transformation - defines the transformation matrix + * @returns the transformed Vector3 + */ + static TransformCoordinates(vector: ReadOnlyVector3, transformation: Matrix): Vector3 + /** + * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector + * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) + * @param vector - defines the Vector3 to transform + * @param transformation - defines the transformation matrix + * @param result - defines the Vector3 where to store the result + */ + static TransformCoordinatesToRef(vector: ReadOnlyVector3, transformation: Readonly, result: Vector3): void + /** + * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z) + * This method computes tranformed coordinates only, not transformed direction vectors + * @param x - define the x coordinate of the source vector + * @param y - define the y coordinate of the source vector + * @param z - define the z coordinate of the source vector + * @param transformation - defines the transformation matrix + * @param result - defines the Vector3 where to store the result + */ + static TransformCoordinatesFromFloatsToRef( + x: number, + y: number, + z: number, + transformation: Readonly, + result: Vector3 + ): void + /** + * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector + * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) + * @param vector - defines the Vector3 to transform + * @param transformation - defines the transformation matrix + * @returns the new Vector3 + */ + static TransformNormal(vector: ReadOnlyVector3, transformation: Matrix): Vector3 + /** + * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector + * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) + * @param vector - defines the Vector3 to transform + * @param transformation - defines the transformation matrix + * @param result - defines the Vector3 where to store the result + */ + static TransformNormalToRef(vector: ReadOnlyVector3, transformation: Readonly, result: Vector3): void + /** + * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z) + * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) + * @param x - define the x coordinate of the source vector + * @param y - define the y coordinate of the source vector + * @param z - define the z coordinate of the source vector + * @param transformation - defines the transformation matrix + * @param result - defines the Vector3 where to store the result + */ + static TransformNormalFromFloatsToRef( + x: number, + y: number, + z: number, + transformation: Readonly, + result: Vector3 + ): void + /** + * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4" + * @param value1 - defines the first control point + * @param value2 - defines the second control point + * @param value3 - defines the third control point + * @param value4 - defines the fourth control point + * @param amount - defines the amount on the spline to use + * @returns the new Vector3 + */ + static CatmullRom( + value1: ReadOnlyVector3, + value2: ReadOnlyVector3, + value3: ReadOnlyVector3, + value4: ReadOnlyVector3, + amount: number + ): Vector3 + /** + * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max" + * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one + * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one + * @param value - defines the current value + * @param min - defines the lower range value + * @param max - defines the upper range value + * @returns the new Vector3 + */ + static Clamp(value: ReadOnlyVector3, min: ReadOnlyVector3, max: ReadOnlyVector3): Vector3 + /** + * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max" + * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one + * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one + * @param value - defines the current value + * @param min - defines the lower range value + * @param max - defines the upper range value + * @param result - defines the Vector3 where to store the result + */ + static ClampToRef(value: ReadOnlyVector3, min: ReadOnlyVector3, max: ReadOnlyVector3, result: Vector3): void + /** + * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2" + * @param value1 - defines the first control point + * @param tangent1 - defines the first tangent vector + * @param value2 - defines the second control point + * @param tangent2 - defines the second tangent vector + * @param amount - defines the amount on the interpolation spline (between 0 and 1) + * @returns the new Vector3 + */ + static Hermite( + value1: ReadOnlyVector3, + tangent1: ReadOnlyVector3, + value2: ReadOnlyVector3, + tangent2: ReadOnlyVector3, + amount: number + ): Vector3 + /** + * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end" + * @param start - defines the start value + * @param end - defines the end value + * @param amount - max defines amount between both (between 0 and 1) + * @returns the new Vector3 + */ + static Lerp(start: ReadOnlyVector3, end: ReadOnlyVector3, amount: number): Vector3 + /** + * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end" + * @param start - defines the start value + * @param end - defines the end value + * @param amount - max defines amount between both (between 0 and 1) + * @param result - defines the Vector3 where to store the result + */ + static LerpToRef(start: ReadOnlyVector3, end: ReadOnlyVector3, amount: number, result: Vector3): void + /** + * Returns the dot product (float) between the vectors "left" and "right" + * @param left - defines the left operand + * @param right - defines the right operand + * @returns the dot product + */ + static Dot(left: ReadOnlyVector3, right: ReadOnlyVector3): number + /** + * Returns a new Vector3 as the cross product of the vectors "left" and "right" + * The cross product is then orthogonal to both "left" and "right" + * @param left - defines the left operand + * @param right - defines the right operand + * @returns the cross product + */ + static Cross(left: ReadOnlyVector3, right: ReadOnlyVector3): Vector3 + /** + * Sets the given vector "result" with the cross product of "left" and "right" + * The cross product is then orthogonal to both "left" and "right" + * @param left - defines the left operand + * @param right - defines the right operand + * @param result - defines the Vector3 where to store the result + */ + static CrossToRef(left: ReadOnlyVector3, right: ReadOnlyVector3, result: Vector3): void + /** + * Returns a new Vector3 as the normalization of the given vector + * @param vector - defines the Vector3 to normalize + * @returns the new Vector3 + */ + static Normalize(vector: Vector3): Vector3 + /** + * Sets the given vector "result" with the normalization of the given first vector + * @param vector - defines the Vector3 to normalize + * @param result - defines the Vector3 where to store the result + */ + static NormalizeToRef(vector: Vector3, result: Vector3): void + /** + * Gets the minimal coordinate values between two Vector3 + * @param left - defines the first operand + * @param right - defines the second operand + * @returns the new Vector3 + */ + static Minimize(left: ReadOnlyVector3, right: ReadOnlyVector3): Vector3 + /** + * Gets the maximal coordinate values between two Vector3 + * @param left - defines the first operand + * @param right - defines the second operand + * @returns the new Vector3 + */ + static Maximize(left: Vector3, right: Vector3): Vector3 + /** + * Returns the distance between the vectors "value1" and "value2" + * @param value1 - defines the first operand + * @param value2 - defines the second operand + * @returns the distance + */ + static Distance(value1: ReadOnlyVector3, value2: ReadOnlyVector3): number + /** + * Returns the squared distance between the vectors "value1" and "value2" + * @param value1 - defines the first operand + * @param value2 - defines the second operand + * @returns the squared distance + */ + static DistanceSquared(value1: ReadOnlyVector3, value2: ReadOnlyVector3): number + /** + * Returns a new Vector3 located at the center between "value1" and "value2" + * @param value1 - defines the first operand + * @param value2 - defines the second operand + * @returns the new Vector3 + */ + static Center(value1: ReadOnlyVector3, value2: ReadOnlyVector3): Vector3 + /** + * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), + * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply + * to something in order to rotate it from its local system to the given target system + * Note: axis1, axis2 and axis3 are normalized during this operation + * @param axis1 - defines the first axis + * @param axis2 - defines the second axis + * @param axis3 - defines the third axis + * @returns a new Vector3 + */ + static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3 + /** + * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3 + * @param axis1 - defines the first axis + * @param axis2 - defines the second axis + * @param axis3 - defines the third axis + * @param ref - defines the Vector3 where to store the result + */ + static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void + /** + * Creates a string representation of the Vector3 + * @returns a string with the Vector3 coordinates. + */ + toString(): string + /** + * Gets the class name + * @returns the string "Vector3" + */ + getClassName(): string + /** + * Creates the Vector3 hash code + * @returns a number which tends to be unique between Vector3 instances + */ + getHashCode(): number + /** + * Creates an array containing three elements : the coordinates of the Vector3 + * @returns a new array of numbers + */ + asArray(): number[] + /** + * Populates the given array or FloatArray from the given index with the successive coordinates of the Vector3 + * @param array - defines the destination array + * @param index - defines the offset in the destination array + * @returns the current Vector3 + */ + toArray(array: FloatArray, index?: number): Vector3 + /** + * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation) + * @returns a new Quaternion object, computed from the Vector3 coordinates + */ + toQuaternion(): Quaternion + /** + * Adds the given vector to the current Vector3 + * @param otherVector - defines the second operand + * @returns the current updated Vector3 + */ + addInPlace(otherVector: ReadOnlyVector3): Vector3 + /** + * Adds the given coordinates to the current Vector3 + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @returns the current updated Vector3 + */ + addInPlaceFromFloats(x: number, y: number, z: number): Vector3 + /** + * Gets a new Vector3, result of the addition the current Vector3 and the given vector + * @param otherVector - defines the second operand + * @returns the resulting Vector3 + */ + add(otherVector: ReadOnlyVector3): Vector3 + /** + * Adds the current Vector3 to the given one and stores the result in the vector "result" + * @param otherVector - defines the second operand + * @param result - defines the Vector3 object where to store the result + * @returns the current Vector3 + */ + addToRef(otherVector: ReadOnlyVector3, result: Vector3): Vector3 + /** + * Subtract the given vector from the current Vector3 + * @param otherVector - defines the second operand + * @returns the current updated Vector3 + */ + subtractInPlace(otherVector: ReadOnlyVector3): Vector3 + /** + * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3 + * @param otherVector - defines the second operand + * @returns the resulting Vector3 + */ + subtract(otherVector: ReadOnlyVector3): Vector3 + /** + * Subtracts the given vector from the current Vector3 and stores the result in the vector "result". + * @param otherVector - defines the second operand + * @param result - defines the Vector3 object where to store the result + * @returns the current Vector3 + */ + subtractToRef(otherVector: ReadOnlyVector3, result: Vector3): Vector3 + /** + * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @returns the resulting Vector3 + */ + subtractFromFloats(x: number, y: number, z: number): Vector3 + /** + * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @param result - defines the Vector3 object where to store the result + * @returns the current Vector3 + */ + subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3 + /** + * Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective + * @param matrix - The transformation matrix + */ + applyMatrix4(matrix: Matrix): void + /** + * Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective and set the given vector "result" with this result + * @param matrix - The transformation matrix + * @param result - defines the Vector3 object where to store the result + * @returns the current Vector3 + */ + applyMatrix4ToRef(matrix: Matrix, result: Vector3): Vector3 + /** + * Rotates the current Vector3 based on the given quaternion + * @param q - defines the Quaternion + * @returns the current Vector3 + */ + rotate(q: Quaternion): Vector3 + /** + * Rotates current Vector3 based on the given quaternion, but applies the rotation to target Vector3. + * @param q - defines the Quaternion + * @param result - defines the target Vector3 + * @returns the current Vector3 + */ + rotateToRef(q: Quaternion, result: Vector3): Vector3 + /** + * Gets a new Vector3 set with the current Vector3 negated coordinates + * @returns a new Vector3 + */ + negate(): Vector3 + /** + * Multiplies the Vector3 coordinates by the float "scale" + * @param scale - defines the multiplier factor + * @returns the current updated Vector3 + */ + scaleInPlace(scale: number): Vector3 + /** + * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale" + * @param scale - defines the multiplier factor + * @returns a new Vector3 + */ + scale(scale: number): Vector3 + /** + * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates + * @param scale - defines the multiplier factor + * @param result - defines the Vector3 object where to store the result + * @returns the current Vector3 + */ + scaleToRef(scale: number, result: Vector3): Vector3 + /** + * Scale the current Vector3 values by a factor and add the result to a given Vector3 + * @param scale - defines the scale factor + * @param result - defines the Vector3 object where to store the result + * @returns the unmodified current Vector3 + */ + scaleAndAddToRef(scale: number, result: Vector3): Vector3 + /** + * Returns true if the current Vector3 and the given vector coordinates are strictly equal + * @param otherVector - defines the second operand + * @returns true if both vectors are equals + */ + equals(otherVector: ReadOnlyVector3): boolean + /** + * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon + * @param otherVector - defines the second operand + * @param epsilon - defines the minimal distance to define values as equals + * @returns true if both vectors are distant less than epsilon + */ + equalsWithEpsilon(otherVector: ReadOnlyVector3, epsilon?: number): boolean + /** + * Returns true if the current Vector3 coordinates equals the given floats + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @returns true if both vectors are equals + */ + equalsToFloats(x: number, y: number, z: number): boolean + /** + * Multiplies the current Vector3 coordinates by the given ones + * @param otherVector - defines the second operand + * @returns the current updated Vector3 + */ + multiplyInPlace(otherVector: ReadOnlyVector3): Vector3 + /** + * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector + * @param otherVector - defines the second operand + * @returns the new Vector3 + */ + multiply(otherVector: ReadOnlyVector3): Vector3 + /** + * Multiplies the current Vector3 by the given one and stores the result in the given vector "result" + * @param otherVector - defines the second operand + * @param result - defines the Vector3 object where to store the result + * @returns the current Vector3 + */ + multiplyToRef(otherVector: ReadOnlyVector3, result: Vector3): Vector3 + /** + * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @returns the new Vector3 + */ + multiplyByFloats(x: number, y: number, z: number): Vector3 + /** + * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones + * @param otherVector - defines the second operand + * @returns the new Vector3 + */ + divide(otherVector: ReadOnlyVector3): Vector3 + /** + * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result" + * @param otherVector - defines the second operand + * @param result - defines the Vector3 object where to store the result + * @returns the current Vector3 + */ + divideToRef(otherVector: ReadOnlyVector3, result: Vector3): Vector3 + /** + * Divides the current Vector3 coordinates by the given ones. + * @param otherVector - defines the second operand + * @returns the current updated Vector3 + */ + divideInPlace(otherVector: ReadOnlyVector3): Vector3 + /** + * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones + * @param other - defines the second operand + * @returns the current updated Vector3 + */ + minimizeInPlace(other: ReadOnlyVector3): Vector3 + /** + * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones. + * @param other - defines the second operand + * @returns the current updated Vector3 + */ + maximizeInPlace(other: ReadOnlyVector3): Vector3 + /** + * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @returns the current updated Vector3 + */ + minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3 + /** + * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates. + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @returns the current updated Vector3 + */ + maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3 + /** + * Gets a new Vector3 from current Vector3 floored values + * @returns a new Vector3 + */ + floor(): Vector3 + /** + * Gets a new Vector3 from current Vector3 floored values + * @returns a new Vector3 + */ + fract(): Vector3 + /** + * Gets the length of the Vector3 + * @returns the length of the Vecto3 + */ + length(): number + /** + * Gets the squared length of the Vector3 + * @returns squared length of the Vector3 + */ + lengthSquared(): number + /** + * Normalize the current Vector3. + * Please note that this is an in place operation. + * @returns the current updated Vector3 + */ + normalize(): Vector3 + /** + * Normalize the current Vector3 with the given input length. + * Please note that this is an in place operation. + * @param len - the length of the vector + * @returns the current updated Vector3 + */ + normalizeFromLength(len: number): Vector3 + /** + * Normalize the current Vector3 to a new vector + * @returns the new Vector3 + */ + normalizeToNew(): Vector3 + /** + * Normalize the current Vector3 to the reference + * @param reference - define the Vector3 to update + * @returns the updated Vector3 + */ + normalizeToRef(reference: Vector3): Vector3 + /** + * Creates a new Vector3 copied from the current Vector3 + * @returns the new Vector3 + */ + clone(): Vector3 + /** + * Copies the given vector coordinates to the current Vector3 ones + * @param source - defines the source Vector3 + * @returns the current updated Vector3 + */ + copyFrom(source: ReadOnlyVector3): Vector3 + /** + * Copies the given floats to the current Vector3 coordinates + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @returns the current updated Vector3 + */ + copyFromFloats(x: number, y: number, z: number): Vector3 + /** + * Copies the given floats to the current Vector3 coordinates + * @param x - defines the x coordinate of the operand + * @param y - defines the y coordinate of the operand + * @param z - defines the z coordinate of the operand + * @returns the current updated Vector3 + */ + set(x: number, y: number, z: number): Vector3 + /** + * Copies the given float to the current Vector3 coordinates + * @param v - defines the x, y and z coordinates of the operand + * @returns the current updated Vector3 + */ + setAll(v: number): Vector3 +} + +/** + * Vector4 class created for EulerAngle class conversion to Quaternion + * @public + */ +declare class Vector4 { + /** x value of the vector */ + x: number + /** y value of the vector */ + y: number + /** z value of the vector */ + z: number + /** w value of the vector */ + w: number + /** + * Creates a Vector4 object from the given floats. + * @param x - x value of the vector + * @param y - y value of the vector + * @param z - z value of the vector + * @param w - w value of the vector + */ + constructor( + /** x value of the vector */ + x: number, + /** y value of the vector */ + y: number, + /** z value of the vector */ + z: number, + /** w value of the vector */ + w: number + ) + /** + * Returns a new Vector4 as the result of the addition of the two given vectors. + * @param vector1 - the first vector + * @param vector2 - the second vector + * @returns the resulting vector + */ + static Add(vector1: ReadOnlyVector4, vector2: ReadOnlyVector4): Vector4 + /** + * Returns a new Vector4 set from the starting index of the given array. + * @param array - the array to pull values from + * @param offset - the offset into the array to start at + * @returns the new vector + */ + static FromArray(array: ArrayLike, offset?: number): Vector4 + /** + * Updates the given vector "result" from the starting index of the given array. + * @param array - the array to pull values from + * @param offset - the offset into the array to start at + * @param result - the vector to store the result in + */ + static FromArrayToRef(array: ArrayLike, offset: number, result: Vector4): void + /** + * Updates the given vector "result" from the starting index of the given FloatArray. + * @param array - the array to pull values from + * @param offset - the offset into the array to start at + * @param result - the vector to store the result in + */ + static FromFloatArrayToRef(array: FloatArray, offset: number, result: Vector4): void + /** + * Updates the given vector "result" coordinates from the given floats. + * @param x - float to set from + * @param y - float to set from + * @param z - float to set from + * @param w - float to set from + * @param result - the vector to the floats in + */ + static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void + /** + * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) + * @returns the new vector + */ + static Zero(): Vector4 + /** + * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) + * @returns the new vector + */ + static One(): Vector4 + /** + * Returns a new normalized Vector4 from the given one. + * @param vector - the vector to normalize + * @returns the vector + */ + static Normalize(vector: ReadOnlyVector4): Vector4 + /** + * Updates the given vector "result" from the normalization of the given one. + * @param vector - the vector to normalize + * @param result - the vector to store the result in + */ + static NormalizeToRef(vector: ReadOnlyVector4, result: Vector4): void + /** + * Returns a vector with the minimum values from the left and right vectors + * @param left - left vector to minimize + * @param right - right vector to minimize + * @returns a new vector with the minimum of the left and right vector values + */ + static Minimize(left: ReadOnlyVector4, right: ReadOnlyVector4): Vector4 + /** + * Returns a vector with the maximum values from the left and right vectors + * @param left - left vector to maximize + * @param right - right vector to maximize + * @returns a new vector with the maximum of the left and right vector values + */ + static Maximize(left: ReadOnlyVector4, right: ReadOnlyVector4): Vector4 + /** + * Returns the distance (float) between the vectors "value1" and "value2". + * @param value1 - value to calulate the distance between + * @param value2 - value to calulate the distance between + * @returns the distance between the two vectors + */ + static Distance(value1: ReadOnlyVector4, value2: ReadOnlyVector4): number + /** + * Returns the squared distance (float) between the vectors "value1" and "value2". + * @param value1 - value to calulate the distance between + * @param value2 - value to calulate the distance between + * @returns the distance between the two vectors squared + */ + static DistanceSquared(value1: ReadOnlyVector4, value2: ReadOnlyVector4): number + /** + * Returns a new Vector4 located at the center between the vectors "value1" and "value2". + * @param value1 - value to calulate the center between + * @param value2 - value to calulate the center between + * @returns the center between the two vectors + */ + static Center(value1: ReadOnlyVector4, value2: ReadOnlyVector4): Vector4 + /** + * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector. + * This methods computes transformed normalized direction vectors only. + * @param vector - the vector to transform + * @param transformation - the transformation matrix to apply + * @returns the new vector + */ + static TransformNormal(vector: ReadOnlyVector4, transformation: Matrix): Vector4 + /** + * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector. + * This methods computes transformed normalized direction vectors only. + * @param vector - the vector to transform + * @param transformation - the transformation matrix to apply + * @param result - the vector to store the result in + */ + static TransformNormalToRef(vector: ReadOnlyVector4, transformation: Matrix, result: Vector4): void + /** + * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w). + * This methods computes transformed normalized direction vectors only. + * @param x - value to transform + * @param y - value to transform + * @param z - value to transform + * @param w - value to transform + * @param transformation - the transformation matrix to apply + * @param result - the vector to store the results in + */ + static TransformNormalFromFloatsToRef( + x: number, + y: number, + z: number, + w: number, + transformation: Matrix, + result: Vector4 + ): void + /** + * Returns the string with the Vector4 coordinates. + * @returns a string containing all the vector values + */ + toString(): string + /** + * Returns the string "Vector4". + * @returns "Vector4" + */ + getClassName(): string + /** + * Returns the Vector4 hash code. + * @returns a unique hash code + */ + getHashCode(): number + /** + * Returns a new array populated with 4 elements : the Vector4 coordinates. + * @returns the resulting array + */ + asArray(): number[] + /** + * Populates the given array from the given index with the Vector4 coordinates. + * @param array - array to populate + * @param index - index of the array to start at (default: 0) + * @returns the Vector4. + */ + toArray(array: FloatArray, index?: number): Vector4 + /** + * Adds the given vector to the current Vector4. + * @param otherVector - the vector to add + * @returns the updated Vector4. + */ + addInPlace(otherVector: ReadOnlyVector4): Vector4 + /** + * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one. + * @param otherVector - the vector to add + * @returns the resulting vector + */ + add(otherVector: ReadOnlyVector4): Vector4 + /** + * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one. + * @param otherVector - the vector to add + * @param result - the vector to store the result + * @returns the current Vector4. + */ + addToRef(otherVector: ReadOnlyVector4, result: Vector4): Vector4 + /** + * Subtract in place the given vector from the current Vector4. + * @param otherVector - the vector to subtract + * @returns the updated Vector4. + */ + subtractInPlace(otherVector: ReadOnlyVector4): Vector4 + /** + * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4. + * @param otherVector - the vector to add + * @returns the new vector with the result + */ + subtract(otherVector: ReadOnlyVector4): Vector4 + /** + * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4. + * @param otherVector - the vector to subtract + * @param result - the vector to store the result + * @returns the current Vector4. + */ + subtractToRef(otherVector: ReadOnlyVector4, result: Vector4): Vector4 + /** + * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates. + */ + /** + * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates. + * @param x - value to subtract + * @param y - value to subtract + * @param z - value to subtract + * @param w - value to subtract + * @returns new vector containing the result + */ + subtractFromFloats(x: number, y: number, z: number, w: number): Vector4 + /** + * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates. + * @param x - value to subtract + * @param y - value to subtract + * @param z - value to subtract + * @param w - value to subtract + * @param result - the vector to store the result in + * @returns the current Vector4. + */ + subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4 + /** + * Returns a new Vector4 set with the current Vector4 negated coordinates. + * @returns a new vector with the negated values + */ + negate(): Vector4 + /** + * Multiplies the current Vector4 coordinates by scale (float). + * @param scale - the number to scale with + * @returns the updated Vector4. + */ + scaleInPlace(scale: number): Vector4 + /** + * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). + * @param scale - the number to scale with + * @returns a new vector with the result + */ + scale(scale: number): Vector4 + /** + * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float). + * @param scale - the number to scale with + * @param result - a vector to store the result in + * @returns the current Vector4. + */ + scaleToRef(scale: number, result: Vector4): Vector4 + /** + * Scale the current Vector4 values by a factor and add the result to a given Vector4 + * @param scale - defines the scale factor + * @param result - defines the Vector4 object where to store the result + * @returns the unmodified current Vector4 + */ + scaleAndAddToRef(scale: number, result: Vector4): Vector4 + /** + * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones. + * @param otherVector - the vector to compare against + * @returns true if they are equal + */ + equals(otherVector: ReadOnlyVector4): boolean + /** + * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones. + * @param otherVector - vector to compare against + * @param epsilon - (Default: very small number) + * @returns true if they are equal + */ + equalsWithEpsilon(otherVector: ReadOnlyVector4, epsilon?: number): boolean + /** + * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates. + * @param x - x value to compare against + * @param y - y value to compare against + * @param z - z value to compare against + * @param w - w value to compare against + * @returns true if equal + */ + equalsToFloats(x: number, y: number, z: number, w: number): boolean + /** + * Multiplies in place the current Vector4 by the given one. + * @param otherVector - vector to multiple with + * @returns the updated Vector4. + */ + multiplyInPlace(otherVector: ReadOnlyVector4): Vector4 + /** + * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one. + * @param otherVector - vector to multiple with + * @returns resulting new vector + */ + multiply(otherVector: ReadOnlyVector4): Vector4 + /** + * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one. + * @param otherVector - vector to multiple with + * @param result - vector to store the result + * @returns the current Vector4. + */ + multiplyToRef(otherVector: ReadOnlyVector4, result: Vector4): Vector4 + /** + * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates. + * @param x - x value multiply with + * @param y - y value multiply with + * @param z - z value multiply with + * @param w - w value multiply with + * @returns resulting new vector + */ + multiplyByFloats(x: number, y: number, z: number, w: number): Vector4 + /** + * Returns a new Vector4 set with the division result of the current Vector4 by the given one. + * @param otherVector - vector to devide with + * @returns resulting new vector + */ + divide(otherVector: ReadOnlyVector4): Vector4 + /** + * Updates the given vector "result" with the division result of the current Vector4 by the given one. + * @param otherVector - vector to devide with + * @param result - vector to store the result + * @returns the current Vector4. + */ + divideToRef(otherVector: ReadOnlyVector4, result: Vector4): Vector4 + /** + * Divides the current Vector3 coordinates by the given ones. + * @param otherVector - vector to devide with + * @returns the updated Vector3. + */ + divideInPlace(otherVector: ReadOnlyVector4): Vector4 + /** + * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones + * @param other - defines the second operand + * @returns the current updated Vector4 + */ + minimizeInPlace(other: ReadOnlyVector4): Vector4 + /** + * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones + * @param other - defines the second operand + * @returns the current updated Vector4 + */ + maximizeInPlace(other: ReadOnlyVector4): Vector4 + /** + * Gets a new Vector4 from current Vector4 floored values + * @returns a new Vector4 + */ + floor(): Vector4 + /** + * Gets a new Vector4 from current Vector3 floored values + * @returns a new Vector4 + */ + fract(): Vector4 + /** + * Returns the Vector4 length (float). + * @returns the length + */ + length(): number + /** + * Returns the Vector4 squared length (float). + * @returns the length squared + */ + lengthSquared(): number + /** + * Normalizes in place the Vector4. + * @returns the updated Vector4. + */ + normalize(): Vector4 + /** + * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. + * @returns this converted to a new vector3 + */ + toVector3(): Vector3 + /** + * Returns a new Vector4 copied from the current one. + * @returns the new cloned vector + */ + clone(): Vector4 + /** + * Updates the current Vector4 with the given one coordinates. + * @param source - the source vector to copy from + * @returns the updated Vector4. + */ + copyFrom(source: ReadOnlyVector4): Vector4 + /** + * Updates the current Vector4 coordinates with the given floats. + * @param x - float to copy from + * @param y - float to copy from + * @param z - float to copy from + * @param w - float to copy from + * @returns the updated Vector4. + */ + copyFromFloats(x: number, y: number, z: number, w: number): Vector4 + /** + * Updates the current Vector4 coordinates with the given floats. + * @param x - float to set from + * @param y - float to set from + * @param z - float to set from + * @param w - float to set from + * @returns the updated Vector4. + */ + set(x: number, y: number, z: number, w: number): Vector4 + /** + * Copies the given float to the current Vector3 coordinates + * @param v - defines the x, y, z and w coordinates of the operand + * @returns the current updated Vector3 + */ + setAll(v: number): Vector4 +} + +declare type double = number + +declare const engine: Engine + +/** + * Error function. Prints a console error. Only works in debug mode, otherwise it does nothing. + * @param error - string or Error object. + * @param data - any debug information. + * @public + */ +declare function error(error: string | Error, data?: any): void + +/** + * Executes an asynchronous task + * @param task - the task to execute + * @beta + */ +declare function executeTask(task: () => Promise): TaskResult + +declare type float = number + +/** + * @public + */ +declare function getComponentClassId = any>( + component: T | ComponentConstructor +): number | null + +/** + * @public + */ +declare function getComponentId(component: T): string + +/** + * @public + */ +declare function getComponentName = any>(component: T | ComponentConstructor): string + +/** + * @public + */ +declare function isDisposableComponent(component: ComponentLike): boolean + +/** + * Log function. Only works in debug mode, otherwise it does nothing. + * @param args - any loggable parameter + * @public + */ +declare function log(...args: any[]): void diff --git a/packages/decentraland-loader/src/parcelScene.ts b/packages/decentraland-loader/src/parcelScene.ts index d689f8fdf..8b46d46aa 100644 --- a/packages/decentraland-loader/src/parcelScene.ts +++ b/packages/decentraland-loader/src/parcelScene.ts @@ -1,7 +1,12 @@ import { parseParcelPosition, isValidParcelSceneShape } from 'atomicHelpers/parcelScenePositions' import { error } from 'engine/logger' import { getLand } from './landLoader' -import { Vector2Component, ILand } from 'shared/types' +import { ILand } from 'shared/types' + +interface Vector2Component { + x: number + y: number +} export class ParcelScene { id: string = '' diff --git a/packages/engine/components/Billboard.ts b/packages/engine/components/Billboard.ts index 36126f215..cd4021e17 100644 --- a/packages/engine/components/Billboard.ts +++ b/packages/engine/components/Billboard.ts @@ -7,10 +7,6 @@ export class Billboard extends BaseComponent { return Math.max(Math.min(7, validators.int(x, 0)), 0) } - attach(entity: BaseEntity) { - super.attach(entity) - } - update() { this.entity.billboardMode = this.value } diff --git a/packages/engine/components/disposableComponents/DisposableComponent.ts b/packages/engine/components/disposableComponents/DisposableComponent.ts index e40ca0b5e..57c3653e7 100644 --- a/packages/engine/components/disposableComponents/DisposableComponent.ts +++ b/packages/engine/components/disposableComponents/DisposableComponent.ts @@ -94,7 +94,6 @@ export abstract class BasicShape extends DisposableComponent { const mesh = this.generateModel() mesh.cullingStrategy = BABYLON.AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY - mesh.actionManager = entity.getActionManager() mesh.isPickable = true entity.setObject3D(BasicShape.nameInEntity, mesh) diff --git a/packages/engine/components/disposableComponents/GLTFShape.ts b/packages/engine/components/disposableComponents/GLTFShape.ts index 053f85de9..88010328f 100644 --- a/packages/engine/components/disposableComponents/GLTFShape.ts +++ b/packages/engine/components/disposableComponents/GLTFShape.ts @@ -70,7 +70,7 @@ export class GLTFShape extends DisposableComponent { // TODO(menduz): what happens if the load ends when the entity got removed? if (!entity.isDisposed()) { - processColliders(assetContainer, entity.getActionManager()) + processColliders(assetContainer) // Fin the main mesh and add it as the BasicShape.nameInEntity component. assetContainer.meshes.filter($ => $.name === '__root__').forEach(mesh => { diff --git a/packages/engine/components/disposableComponents/OBJShape.ts b/packages/engine/components/disposableComponents/OBJShape.ts index 965733807..9292d4c7f 100644 --- a/packages/engine/components/disposableComponents/OBJShape.ts +++ b/packages/engine/components/disposableComponents/OBJShape.ts @@ -52,7 +52,7 @@ export class OBJShape extends DisposableComponent { if (!entity.isDisposed()) { this.assetContainerEntity.set(entity.uuid, assetContainer) - processColliders(assetContainer, entity.getActionManager()) + processColliders(assetContainer) const node = new BABYLON.AbstractMesh('obj') diff --git a/packages/engine/components/disposableComponents/ui/UIImage.ts b/packages/engine/components/disposableComponents/ui/UIImage.ts index ac58695fc..597d02249 100644 --- a/packages/engine/components/disposableComponents/ui/UIImage.ts +++ b/packages/engine/components/disposableComponents/ui/UIImage.ts @@ -6,7 +6,6 @@ import { parseVerticalAlignment, parseHorizontalAlignment } from 'engine/entitie import { UIImageShape } from 'decentraland-ecs/src/decentraland/UIShapes' import { SharedSceneContext } from 'engine/entities/SharedSceneContext' import { UIControl } from './UIControl' -import { PointerLock } from 'engine/renderer/input' const schemaValidator = createSchemaValidator({ id: { type: 'string', default: null }, @@ -37,7 +36,6 @@ class Class extends UIControl { super(ctx, uuid) this.control.onPointerUpObservable.add($ => { - this.checkPointerLock() this.dispatchOnClick($.buttonIndex) }) } @@ -87,18 +85,10 @@ class Class extends UIControl { dispatchOnClick = (pointerId: number) => { this.entities.forEach($ => $.dispatchUUIDEvent('onClick', { - entityId: $.uuid, - pointerId + entityId: $.uuid }) ) } - - checkPointerLock = () => { - if (this.data.isPointerBlocker) { - PointerLock.isLocked = false - PointerLock.preventLocking = true - } - } } DisposableComponent.registerClassId(CLASS_ID.UI_IMAGE_SHAPE, Class) diff --git a/packages/engine/components/disposableComponents/ui/UIInputText.ts b/packages/engine/components/disposableComponents/ui/UIInputText.ts index bf0dc3c7c..83c0d3393 100644 --- a/packages/engine/components/disposableComponents/ui/UIInputText.ts +++ b/packages/engine/components/disposableComponents/ui/UIInputText.ts @@ -6,7 +6,6 @@ import { parseVerticalAlignment, parseHorizontalAlignment } from 'engine/entitie import { UIInputTextShape } from 'decentraland-ecs/src/decentraland/UIShapes' import { SharedSceneContext } from 'engine/entities/SharedSceneContext' import { UIControl } from './UIControl' -import { PointerLock } from 'engine/renderer/input' import { IEvents } from 'decentraland-ecs/src/decentraland/Types' const schemaValidator = createSchemaValidator({ @@ -50,15 +49,12 @@ class Class extends UIControl { super(ctx, uuid) this.control.onTextChangedObservable.add($ => { - this.checkPointerLock() this.dispatchOnChanged({ pointerId: -1, value: $.text }) }) this.control.onFocusObservable.add(_ => { - this.checkPointerLock() this.dispatchOnFocus({ entityId: this.uuid, pointerId: -1 }) }) this.control.onBlurObservable.add(_ => { - this.checkPointerLock() this.dispatchOnBlur({ entityId: this.uuid, pointerId: -1 }) }) } @@ -126,13 +122,6 @@ class Class extends UIControl { this.setParent(this.data.parentComponent) } - checkPointerLock = () => { - if (this.data.isPointerBlocker) { - PointerLock.isLocked = false - PointerLock.preventLocking = true - } - } - dispatchOnChanged = (data: IEvents['onChange']) => { this.entities.forEach($ => $.dispatchUUIDEvent('onChange', data)) } diff --git a/packages/engine/components/disposableComponents/ui/UISlider.ts b/packages/engine/components/disposableComponents/ui/UISlider.ts index 30ed59a3e..dda54f245 100644 --- a/packages/engine/components/disposableComponents/ui/UISlider.ts +++ b/packages/engine/components/disposableComponents/ui/UISlider.ts @@ -6,7 +6,6 @@ import { parseVerticalAlignment, parseHorizontalAlignment } from 'engine/entitie import { UISliderShape } from 'decentraland-ecs/src/decentraland/UIShapes' import { SharedSceneContext } from 'engine/entities/SharedSceneContext' import { UIControl } from './UIControl' -import { PointerLock } from 'engine/renderer/input' import { IEvents } from 'decentraland-ecs/src/decentraland/Types' const schemaValidator = createSchemaValidator({ @@ -45,7 +44,6 @@ class Class extends UIControl { super(ctx, uuid) this.control.onValueChangedObservable.add($ => { - this.checkPointerLock() this.dispatchOnChanged({ pointerId: -1, value: $ }) }) } @@ -109,13 +107,6 @@ class Class extends UIControl { dispatchOnChanged = (data: IEvents['onChange']) => { this.entities.forEach($ => $.dispatchUUIDEvent('onChange', data)) } - - checkPointerLock = () => { - if (this.data.isPointerBlocker) { - PointerLock.isLocked = false - PointerLock.preventLocking = true - } - } } DisposableComponent.registerClassId(CLASS_ID.UI_SLIDER_SHAPE, Class) diff --git a/packages/engine/components/ephemeralComponents/Gizmos.ts b/packages/engine/components/ephemeralComponents/Gizmos.ts index 8779a0098..50f5ddb29 100644 --- a/packages/engine/components/ephemeralComponents/Gizmos.ts +++ b/packages/engine/components/ephemeralComponents/Gizmos.ts @@ -9,7 +9,7 @@ type GizmoConfiguration = { scale: boolean cycle: boolean localReference: boolean - selectedGizmo: Gizmo + selectedGizmo?: Gizmo } export const gizmoManager = new BABYLON.GizmoManager(scene) @@ -24,8 +24,7 @@ const defaultValue: GizmoConfiguration = { rotation: true, scale: true, cycle: true, - localReference: false, - selectedGizmo: Gizmo.MOVE + localReference: false } let activeEntity: BaseEntity = null @@ -82,7 +81,6 @@ function switchGizmo() { { gizmoManager.gizmos.positionGizmo.onDragEndObservable.add(() => { if (!activeEntity) return - activeEntity.dispatchUUIDEvent('gizmoEvent', { type: 'gizmoDragEnded', transform: { @@ -161,20 +159,14 @@ export class Gizmos extends BaseComponent { activate = () => { this.configureGizmos() - if (this.entity === activeEntity) { - if (currentConfiguration.cycle) { - selectGizmo(switchGizmo()) - } else { - if (isSelectedGizmoValid()) { - selectGizmo(selectedGizmo) - } else { - selectGizmo(switchGizmo()) - } - } + if (currentConfiguration.cycle && this.entity === activeEntity) { + selectGizmo(switchGizmo()) } else { activeEntity = this.entity - if (isSelectedGizmoValid()) { + if (currentConfiguration.selectedGizmo) { + selectGizmo(currentConfiguration.selectedGizmo) + } else if (isSelectedGizmoValid()) { selectGizmo(selectedGizmo) } else { selectGizmo(switchGizmo()) @@ -196,7 +188,6 @@ export class Gizmos extends BaseComponent { gizmoManager.gizmos.positionGizmo.updateGizmoPositionToMatchAttachedMesh = !isWorldCoordinates gizmoManager.gizmos.positionGizmo.updateGizmoRotationToMatchAttachedMesh = !isWorldCoordinates gizmoManager.gizmos.scaleGizmo.updateGizmoPositionToMatchAttachedMesh = !isWorldCoordinates - gizmoManager.gizmos.scaleGizmo.updateGizmoRotationToMatchAttachedMesh = !isWorldCoordinates gizmoManager.gizmos.rotationGizmo.updateGizmoRotationToMatchAttachedMesh = !isWorldCoordinates gizmoManager.gizmos.rotationGizmo.updateGizmoPositionToMatchAttachedMesh = !isWorldCoordinates } @@ -208,6 +199,7 @@ export class Gizmos extends BaseComponent { } attach(entity: BaseEntity) { + super.attach(entity) entity.addListener('onClick', this.activate) } diff --git a/packages/engine/components/ephemeralComponents/HighlightBox.ts b/packages/engine/components/ephemeralComponents/HighlightBox.ts index 689ed5e2a..2ff6c86de 100644 --- a/packages/engine/components/ephemeralComponents/HighlightBox.ts +++ b/packages/engine/components/ephemeralComponents/HighlightBox.ts @@ -34,7 +34,8 @@ export class HighlightBox extends BaseComponent<{ highlight: boolean }> { update() { const newValue = !this.value || this.value.highlight - const mesh: BABYLON.Mesh = this.entity.getObject3D(BasicShape.nameInEntity) as any + const mesh: BABYLON.AbstractMesh = this.entity.getObject3D(BasicShape.nameInEntity) as any + if (mesh) { const didChange = mesh.renderOverlay !== !!newValue mesh.renderOverlay = !!newValue @@ -54,10 +55,10 @@ export class HighlightBox extends BaseComponent<{ highlight: boolean }> { } detach() { - const mesh: BABYLON.Mesh = this.entity.getObject3D(BasicShape.nameInEntity) as any + const mesh: BABYLON.AbstractMesh = this.entity.getObject3D(BasicShape.nameInEntity) as any if (mesh) { mesh.renderOverlay = false - mesh.renderOverlay = false + mesh.showBoundingBox = false mesh.overlayColor = new BABYLON.Color3() const children = mesh.getChildTransformNodes(false, filterMeshes) as BABYLON.AbstractMesh[] diff --git a/packages/engine/components/ephemeralComponents/TextShape.ts b/packages/engine/components/ephemeralComponents/TextShape.ts index 3ae8d56cf..7910bae76 100644 --- a/packages/engine/components/ephemeralComponents/TextShape.ts +++ b/packages/engine/components/ephemeralComponents/TextShape.ts @@ -72,8 +72,7 @@ export class TextShape extends BaseComponent { this.textBlock.onPointerUpObservable.add($ => { this.entity.dispatchUUIDEvent('onClick', { - entityId: this.entity.uuid, - pointerId: $.buttonIndex + entityId: this.entity.uuid }) }) } diff --git a/packages/engine/components/ephemeralComponents/Transform.ts b/packages/engine/components/ephemeralComponents/Transform.ts index cbbe833de..daede55fa 100644 --- a/packages/engine/components/ephemeralComponents/Transform.ts +++ b/packages/engine/components/ephemeralComponents/Transform.ts @@ -1,8 +1,7 @@ import { BaseComponent } from '../BaseComponent' import { validators } from '../helpers/schemaValidator' import { BaseEntity } from 'engine/entities/BaseEntity' -import { Vector3Component } from 'atomicHelpers/vectorHelpers' -import { CLASS_ID } from 'decentraland-ecs/src' +import { CLASS_ID, ReadOnlyVector3, ReadOnlyQuaternion } from 'decentraland-ecs/src' const defaultValue = { position: { x: 0, y: 0, z: 0 }, @@ -56,7 +55,7 @@ export class Transform extends BaseComponent { export function setEntityTransform( entity: BaseEntity, - transform: { position?: Vector3Component; scale?: Vector3Component; rotation?: Vector3Component & { w: number } } + transform: { position?: ReadOnlyVector3; scale?: ReadOnlyVector3; rotation?: ReadOnlyQuaternion } ) { entity.context.UpdateEntityComponent({ classId: CLASS_ID.TRANSFORM, diff --git a/packages/engine/components/helpers/schemaValidator.ts b/packages/engine/components/helpers/schemaValidator.ts index 1f64613f0..7a802833b 100644 --- a/packages/engine/components/helpers/schemaValidator.ts +++ b/packages/engine/components/helpers/schemaValidator.ts @@ -1,5 +1,5 @@ import * as BABYLON from 'babylonjs' -import { Vector2Component, Vector3Component, QuaternionComponent } from 'shared/types' +import { ReadOnlyVector2, ReadOnlyVector3, ReadOnlyQuaternion } from 'decentraland-ecs/src' export type ISchema = { [key: string]: { type: keyof Keys; default?: any } } export type Validator = (x: any, defaultValue: T) => T @@ -70,7 +70,7 @@ export const validators = { return String(x) }, - vector2(value: any, def: Vector2Component): Vector2Component { + vector2(value: any, def: ReadOnlyVector2): ReadOnlyVector2 { if (value === null || value === undefined) return def if (Number.isFinite(value)) { @@ -87,7 +87,7 @@ export const validators = { } }, - vector3(value: any, def: Vector3Component): Vector3Component { + vector3(value: any, def: ReadOnlyVector3): ReadOnlyVector3 { if (value === null || value === undefined) return def if (Number.isFinite(value)) { @@ -104,7 +104,7 @@ export const validators = { } }, - quaternion(value: any, def: QuaternionComponent): QuaternionComponent { + quaternion(value: any, def: ReadOnlyQuaternion): ReadOnlyQuaternion { if (value === null || value === undefined) return def if (Number.isFinite(value)) { diff --git a/packages/engine/entities/BaseEntity.ts b/packages/engine/entities/BaseEntity.ts index 4ad66d60b..c40f2bfd4 100644 --- a/packages/engine/entities/BaseEntity.ts +++ b/packages/engine/entities/BaseEntity.ts @@ -37,7 +37,6 @@ export class BaseEntity extends BABYLON.AbstractMesh { assetContainer: BABYLON.AssetContainer isDCLEntity = true - actionManager: BABYLON.ActionManager attrs: Props = {} components: { [key: string]: BaseComponent } = {} @@ -45,7 +44,6 @@ export class BaseEntity extends BABYLON.AbstractMesh { onChangeObject3DObservable = new BABYLON.Observable<{ type: string; object: BABYLON.TransformNode }>() sendPositionsPending = false - sendMetricsPending = false loadingDone = true previousWorldMatrix = BABYLON.Matrix.Zero() @@ -184,12 +182,23 @@ export class BaseEntity extends BABYLON.AbstractMesh { }) if (type === BasicShape.nameInEntity) { - this.getActionManager() this.sendUpdatePositions() this.sendUpdateMetrics() } } + /** + * This method is called after processing an input. It first searches + * for a collision mesh, then it traverses up the tree until it finds an entity + * (this entity) and then it calls this method. + */ + handleClick(pointerEvent: 'pointerUp' | 'pointerDown', pointerId: number, pickingResult: BABYLON.PickingInfo): any { + if (pointerEvent === 'pointerDown') { + this.dispatchUUIDEvent('onClick', { entityId: this.uuid }) + } + this.context.sendPointerEvent(pointerEvent, pointerId, this.uuid, pickingResult) + } + /** * Remove object from scene and entity Object3D map. */ @@ -304,11 +313,6 @@ export class BaseEntity extends BABYLON.AbstractMesh { // Remove the components, behaviors and other stuff super.dispose(true, false) - if (this.actionManager) { - this.actionManager.dispose() - delete this.actionManager - } - if (this.context) { this.context.entities.delete(this.uuid) delete this.context @@ -396,35 +400,15 @@ export class BaseEntity extends BABYLON.AbstractMesh { if (payload.classId === CLASS_ID.UUID_CALLBACK) { const uuidPayload: { type: IEventNames; uuid: string } = JSON.parse(payload.json) this.addUUIDEvent(uuidPayload.type, uuidPayload.uuid) - } - - if (name in this.components) { + } else if (name in this.components) { this.components[name].setValue(JSON.parse(payload.json)) } else if (payload.classId in componentRegistry) { const behavior: BaseComponent = new componentRegistry[payload.classId](this, JSON.parse(payload.json)) this.components[name] = behavior - this.addBehavior(behavior) + this.addBehavior(behavior, true) } } - getActionManager() { - if (this.actionManager) { - return this.actionManager - } - - this.actionManager = new BABYLON.ActionManager(this.getScene()) - this.actionManager.registerAction( - new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickDownTrigger, evt => { - this.dispatchUUIDEvent('onClick', { - entityId: this.uuid, - pointerId: evt.sourceEvent.pointerId || 0 - }) - }) - ) - - return this.actionManager - } - sendUpdatePositions = () => { this.sendPositionsPending = false if (!this._isDisposed) { @@ -434,15 +418,20 @@ export class BaseEntity extends BABYLON.AbstractMesh { } sendUpdateMetrics() { - if (!this.sendMetricsPending) { - this.sendMetricsPending = true - if (!this._isDisposed) { - engineMicroQueue.queueMicroTask(() => { - this.sendMetricsPending = false - this.context && this.context.updateMetrics() - }) - } - } + this.context && this.context.updateMetrics() + } + + getMeshesBoundingBox() { + let children = this.getChildMeshes(false) + let boundingInfo = children[0].getBoundingInfo() + let min = boundingInfo.boundingBox.minimumWorld + let max = boundingInfo.boundingBox.maximumWorld + for (let i = 1; i < children.length; i++) { + boundingInfo = children[i].getBoundingInfo() + min = BABYLON.Vector3.Minimize(min, boundingInfo.boundingBox.minimumWorld) + max = BABYLON.Vector3.Maximize(max, boundingInfo.boundingBox.maximumWorld) + } + return new BABYLON.BoundingInfo(min, max) } } diff --git a/packages/engine/entities/InputTextEntity.ts b/packages/engine/entities/InputTextEntity.ts deleted file mode 100644 index 6a80e4a18..000000000 --- a/packages/engine/entities/InputTextEntity.ts +++ /dev/null @@ -1,90 +0,0 @@ -import * as BABYLON from 'babylonjs' -import { scene } from '../renderer' -import { BaseEntity } from './BaseEntity' - -// const schemaValidator = createSchemaValidator({ -// color: { type: 'string', default: '#000' }, -// fontFamily: { type: 'string', default: 'Arial' }, -// fontSize: { type: 'number', default: 48 }, -// value: { type: 'string', default: '' }, -// width: { type: 'number', default: 1 }, -// height: { type: 'number', default: 1 }, -// background: { type: 'string', default: '#fff' }, -// focusedBackground: { type: 'string', default: '#fff' }, -// outlineWidth: { type: 'number', default: 0 }, -// placeholder: { type: 'string', default: '' }, -// maxLength: { type: 'number', default: 140 } -// }) - -export class InputTextEntity extends BaseEntity { - private mesh: BABYLON.Mesh - private texture: BABYLON.GUI.AdvancedDynamicTexture - private input: BABYLON.GUI.InputText - - dispose() { - if (this.texture) { - this.texture.removeControl(this.input) - this.texture.dispose() - delete this.texture - } - - if (this.mesh) { - this.mesh.dispose(false, true) - delete this.mesh - } - - super.dispose() - } - - setAttributes(attrs) { - // TODO: ECS - // 1 const newAttrs = schemaValidator(Object.assign({}, this.attrs, attrs)) - // 1 super.setAttributes(newAttrs) - - if (!this.mesh) { - this.generateGeometry() - } else { - this.setInputAttributes() - } - } - - generateGeometry() { - this.mesh = BABYLON.MeshBuilder.CreatePlane( - 'plane-input', - { width: this.attrs.width, height: this.attrs.height }, - scene - ) - this.texture = BABYLON.GUI.AdvancedDynamicTexture.CreateForMesh( - this.mesh, - 512 * this.attrs.width, - 512 * this.attrs.height, - false - ) - this.input = new BABYLON.GUI.InputText() - - this.input.onTextChangedObservable.add(inputText => { - this.dispatchUUIDEvent('onChange', { - value: inputText.text - }) - }) - - this.setInputAttributes() - - this.texture.addControl(this.input) - - this.setObject3D('mesh', this.mesh) - } - - setInputAttributes() { - this.input.color = this.attrs.color - this.input.text = this.attrs.maxLength ? this.attrs.value.substr(0, this.attrs.maxLength) : this.attrs.value - this.input.width = this.attrs.width - this.input.height = this.attrs.height - this.input.background = this.attrs.background - this.input.focusedBackground = this.attrs.focusedBackground - this.input.fontFamily = this.attrs.fontFamily - this.input.fontSize = this.attrs.fontSize - this.input.thickness = this.attrs.outlineWidth - this.input.placeholderText = this.attrs.placeholder - } -} diff --git a/packages/engine/entities/SharedSceneContext.ts b/packages/engine/entities/SharedSceneContext.ts index f70046d0d..6b0a4199e 100644 --- a/packages/engine/entities/SharedSceneContext.ts +++ b/packages/engine/entities/SharedSceneContext.ts @@ -24,7 +24,7 @@ import { ILogger, defaultLogger } from 'shared/logger' import { EventDispatcher } from 'decentraland-rpc/lib/common/core/EventDispatcher' import { IParcelSceneLimits } from 'atomicHelpers/landHelpers' import { measureObject3D } from 'dcl/entities/utils/checkParcelSceneLimits' -import { IEventNames, IEvents } from 'decentraland-ecs/src/decentraland/Types' +import { IEventNames, IEvents, PointerEvent } from 'decentraland-ecs/src/decentraland/Types' function validateHierarchy(entity: BaseEntity) { let parent = entity @@ -86,60 +86,65 @@ export class SharedSceneContext implements BABYLON.IDisposable { public readonly internalBaseUrl: string - // TODO(menduz): replace this by a properties/configuration bag - hideAxis?: boolean - isInternal?: boolean - private textureSet: Set = new Set() private _disposed = false private eventSubscriber = new EventDispatcher() + private shouldUpdateMetrics = true constructor(public baseUrl: string, public readonly domain: string, public useMappings: boolean = true) { this.internalBaseUrl = domain ? `dcl://${domain}/` : baseUrl registerLoadingContext(this) + scene.onAfterRenderObservable.add(this.afterRenderScene) } - /** - * Counts and aggregates the number of triangles materials and entities - */ - updateMetrics() { - let entities = 0 - let triangles = 0 - let bodies = 0 - let textures = 0 - let materials = 0 - let geometries = 0 - - this.disposableComponents.forEach($ => { - textures += $.contributions.textureCount - materials += $.contributions.materialCount - geometries += $.contributions.geometriesCount - }) - - textures += this.textures.size - - entities++ - - const childrenMeshes = this.rootEntity.getChildTransformNodes(false, node => { - if ('isDCLEntity' in node) { - entities++ + afterRenderScene = () => { + if (this.shouldUpdateMetrics === true) { + this.shouldUpdateMetrics = false + let entities = 0 + let triangles = 0 + let bodies = 0 + let textures = 0 + let materials = 0 + let geometries = 0 + + this.disposableComponents.forEach($ => { + textures += $.contributions.textureCount + materials += $.contributions.materialCount + geometries += $.contributions.geometriesCount + }) + + // TODO:(agus) textures += this.textures.size + + entities++ + + const childrenMeshes = this.rootEntity.getChildTransformNodes(false, node => { + if ('isDCLEntity' in node) { + entities++ + } + return node instanceof BABYLON.AbstractMesh + }) + + for (let i = 0; i < childrenMeshes.length; i++) { + const r = measureObject3D(childrenMeshes[i]) + entities += r.entities + triangles += r.triangles + bodies += r.bodies } - return node instanceof BABYLON.AbstractMesh - }) - for (let i = 0; i < childrenMeshes.length; i++) { - const r = measureObject3D(childrenMeshes[i]) - entities += r.entities - triangles += r.triangles - bodies += r.bodies - } + this.metrics = { entities, triangles, bodies, textures, materials, geometries } - this.metrics = { entities, triangles, bodies, textures, materials, geometries } + this.emit('metricsUpdate', { + given: this.metrics, + limit: this.metricsLimits + }) + } + } - this.emit('metricsUpdate', { - given: this.metrics, - limit: this.metricsLimits - }) + /** + * Counts and aggregates the number of triangles materials and entities + */ + updateMetrics() { + this.shouldUpdateMetrics = true } on(event: T, cb: (data: IEvents[T]) => void) { @@ -158,6 +163,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { if (!entity) return this.logger.error(`UpdateEntityComponent: Entity ${payload.entityId} doesn't exist`) /// 2) E.UpdateComponent(Name, ClassID, JSON) entity.updateComponent(payload) + + this.shouldUpdateMetrics = true } /// #ECS.AttachEntityComponent: Attach the disposable component C to the entity E @@ -172,6 +179,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { if (!component) return this.logger.error(`AttachEntityComponent: Component ${payload.id} doesn't exist`) /// 4) E.attachDisposableComponent(slotName, C) entity.attachDisposableComponent(payload.name, component) + + this.shouldUpdateMetrics = true } /// #ECS.ComponentCreated: Creates a disposable component C by `classID` and stores it by ID @@ -190,6 +199,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { const C = new (K as any)(this, payload.id) /// 3) Register C in the map of disposable components this.disposableComponents.set(payload.id, C) + + this.shouldUpdateMetrics = true } /// #ECS.ComponentDisposed: Disposes a disposable component C and releases all of it allocated resources @@ -202,6 +213,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { component.dispose() /// 3) Remove component C from map of disposable components this.disposableComponents.delete(payload.id) + + this.shouldUpdateMetrics = true } /// #ECS.ComponentRemoved: Removes a component by Name from an entity E @@ -212,6 +225,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { if (!entity) return this.logger.error(`ComponentRemoved: Entity ${payload.entityId} doesn't exist`) /// 2) remove the component Name from E entity.removeComponentByName(payload.name) + + this.shouldUpdateMetrics = true } /// #ECS.ComponentUpdated: Updates a disposable component C using a JSON payload @@ -222,6 +237,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { if (!component) return this.logger.error(`ComponentUpdated: Component ${payload.id} doesn't exist`) /// 2) C.Update(JSON) component.updateData(JSON.parse(payload.json)).catch($ => this.logger.error('ComponentUpdated', $)) + + this.shouldUpdateMetrics = true } /// #ECS.CreateEntity @@ -236,6 +253,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { E.setParentEntity(this.rootEntity) /// 4) Add entity E to the entity map this.entities.set(payload.id, E) + + this.shouldUpdateMetrics = true } /// #ECS.RemoveEntity @@ -255,6 +274,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { entity.dispose() /// 5) Remove E from the entity list this.entities.delete(payload.id) + + this.shouldUpdateMetrics = true } /// #ECS.SetEntityParent: Set the entity E as child of entity P @@ -294,6 +315,46 @@ export class SharedSceneContext implements BABYLON.IDisposable { }) } + sendPointerEvent( + pointerEventType: 'pointerDown' | 'pointerUp', + pointerId: number, + entityId: string, + pickingResult: BABYLON.PickingInfo + ) { + if (!pickingResult.ray) return + + const event: PointerEvent = { + pointerId, + origin: { + x: pickingResult.ray.origin.x - this.rootEntity.position.x, + y: pickingResult.ray.origin.y - this.rootEntity.position.y, + z: pickingResult.ray.origin.z - this.rootEntity.position.z + }, + direction: pickingResult.ray.direction + } + + if (pickingResult.hit && entityId) { + event.hit = { + length: pickingResult.distance, + hitPoint: { + x: pickingResult.pickedPoint.x - this.rootEntity.position.x, + y: pickingResult.pickedPoint.y - this.rootEntity.position.y, + z: pickingResult.pickedPoint.z - this.rootEntity.position.z + }, + normal: pickingResult.getNormal(), + worldNormal: pickingResult.getNormal(true), + meshName: pickingResult.pickedMesh.name, + entityId + } + } + + if (pointerEventType === 'pointerDown') { + this.emit('pointerDown', event) + } else if (pointerEventType === 'pointerUp') { + this.emit('pointerUp', event) + } + } + public registerTexture(texture: BABYLON.Texture): any { this.textureSet.add(texture) texture.onDisposeObservable.add(this.textureGotRemoved) @@ -387,6 +448,8 @@ export class SharedSceneContext implements BABYLON.IDisposable { } public dispose() { + scene.onAfterRenderObservable.removeCallback(this.afterRenderScene) + if (this.rootEntity) { this.rootEntity.disposeTree(this.entities) diff --git a/packages/engine/entities/utils/processModels.ts b/packages/engine/entities/utils/processModels.ts index 09bcabe6f..884fe9543 100644 --- a/packages/engine/entities/utils/processModels.ts +++ b/packages/engine/entities/utils/processModels.ts @@ -54,7 +54,7 @@ export function cleanupAssetContainer($: BABYLON.AssetContainer) { } } -export function processColliders($: BABYLON.AssetContainer, actionManager: BABYLON.ActionManager) { +export function processColliders($: BABYLON.AssetContainer) { for (let i = 0; i < $.meshes.length; i++) { let mesh = $.meshes[i] @@ -65,7 +65,6 @@ export function processColliders($: BABYLON.AssetContainer, actionManager: BABYL markAsCollider(mesh) } else { mesh.isPickable = true - mesh.actionManager = actionManager } } } diff --git a/packages/engine/renderer/ambientConfigurations.ts b/packages/engine/renderer/ambientConfigurations.ts index b741e303d..f11ef2138 100644 --- a/packages/engine/renderer/ambientConfigurations.ts +++ b/packages/engine/renderer/ambientConfigurations.ts @@ -6,4 +6,8 @@ export namespace ambientConfigurations { export const sunColor = new BABYLON.Color3(1, 1, 1) export const sunPosition = new BABYLON.Vector3(-1, 0.01, 0.3).scaleInPlace(500) export const sunPositionColor = new BABYLON.Color3(sunPosition.x, sunPosition.y, sunPosition.z) + + export const RED = BABYLON.Color3.FromHexString('#ff004f') + export const GREEN = BABYLON.Color3.FromHexString('#00e57a') + export const BLUE = BABYLON.Color3.FromHexString('#00beff') } diff --git a/packages/engine/renderer/camera.ts b/packages/engine/renderer/camera.ts index 3a53ca980..175303a09 100644 --- a/packages/engine/renderer/camera.ts +++ b/packages/engine/renderer/camera.ts @@ -114,37 +114,16 @@ function moveCamera(camera: any, directionRotation: BABYLON.Quaternion, speed: n export { vrCamera, arcCamera } -function setUpEvents(attach: boolean) { - const canvas = engine.getRenderingCanvas() - const eventPrefix = BABYLON.Tools.GetPointerPrefix() - - canvas.removeEventListener(eventPrefix + 'move', (scene as any)._onPointerMove) - canvas.removeEventListener(eventPrefix + 'down', (scene as any)._onPointerDown) - window.removeEventListener(eventPrefix + 'up', (scene as any)._onPointerUp) - - if (attach) { - canvas.addEventListener(eventPrefix + 'move', (scene as any)._onPointerMove) - canvas.addEventListener(eventPrefix + 'down', (scene as any)._onPointerDown) - window.addEventListener(eventPrefix + 'up', (scene as any)._onPointerUp) - } -} - export function setCamera(thirdPerson: boolean) { if (thirdPerson && scene.activeCamera === arcCamera) return if (!thirdPerson && scene.activeCamera === vrCamera) return if (thirdPerson) { - setUpEvents(true) - arcCamera.target.copyFrom(scene.activeCamera.position) - scene.switchActiveCamera(arcCamera) scene.cameraToUseForPointers = scene.activeCamera } else { - setUpEvents(false) - vrCamera.position.copyFrom(scene.activeCamera.position) - scene.switchActiveCamera(vrCamera) scene.cameraToUseForPointers = scene.activeCamera } diff --git a/packages/engine/renderer/index.ts b/packages/engine/renderer/index.ts index 5d7027394..1283de8dd 100644 --- a/packages/engine/renderer/index.ts +++ b/packages/engine/renderer/index.ts @@ -4,7 +4,6 @@ import bodyScrollLock = require('body-scroll-lock') BABYLON.DebugLayer.InspectorURL = require('url-loader!babylonjs-inspector') import { TaskQueue } from 'atomicHelpers/taskQueue' -import { Vector3Component, Vector2Component } from 'atomicHelpers/landHelpers' import { isMobile } from 'shared/comms/mobile' import { error } from '../logger' @@ -13,6 +12,7 @@ import { scene, domReadyFuture, canvas, engine, audioEngine, vrHelper } from './ import { vrCamera } from './camera' import './ambientLights' import { resizeRotationCanvas } from './input' +import { ReadOnlyVector3, ReadOnlyVector2 } from 'decentraland-ecs/src' const engineMicroQueue = new TaskQueue() @@ -120,7 +120,7 @@ export function setSize(w: number, h: number) { onWindowResize() } -export function initLocalPlayer(initialPosition?: Vector3Component, initialRotation?: Vector2Component) { +export function initLocalPlayer(initialPosition?: ReadOnlyVector3, initialRotation?: ReadOnlyVector2) { vrCamera.position.x = initialPosition.x || 0 vrCamera.position.z = initialPosition.z || 0 diff --git a/packages/engine/renderer/input.ts b/packages/engine/renderer/input.ts index 1ccaa6687..1cd72dbc2 100644 --- a/packages/engine/renderer/input.ts +++ b/packages/engine/renderer/input.ts @@ -1,11 +1,12 @@ import * as BABYLON from 'babylonjs' import { playerConfigurations, DEBUG } from 'config' -import { vrHelper, scene } from './init' +import { scene } from './init' import Joystick from './controls/joystick' import PlaneCanvasControl from './controls/planeCanvasControl' -import { isMobile } from 'shared/comms/mobile' import { isThirdPersonCamera, vrCamera } from './camera' +import { loadedParcelSceneWorkers } from 'shared/world/parcelSceneManager' +import { WebGLScene } from 'dcl/WebGLScene' /** * This is a map of keys (see enum Keys): boolean @@ -15,11 +16,6 @@ const keyState: { [keyName: string]: boolean } = {} -const PointerLock = { - isLocked: false, - preventLocking: false -} - enum Keys { KEY_W = 87, KEY_A = 65, @@ -42,12 +38,7 @@ enum Keys { /// --- EXPORTS --- -export { keyState, PointerLock, Keys } - -export function blockPointerLock() { - PointerLock.isLocked = false - PointerLock.preventLocking = true -} +export { keyState, Keys } export function initKeyboard() { vrCamera.keysUp = [Keys.KEY_W as number] // W @@ -148,7 +139,7 @@ function enableRotationCanvas(sceneCanvas: HTMLCanvasElement) { const { x, y } = e.center console['log'](`clicking ${x}, ${y}`) - interactWithScene(e, x, y) + interactWithScene('pointerDown', x, y, 1) }) container.appendChild(canvas) @@ -158,35 +149,39 @@ function enableRotationCanvas(sceneCanvas: HTMLCanvasElement) { resizeRotationCanvas(sceneCanvas) } -function interactWithScene(e, x, y) { - const pickingResult = scene.pick(x, y) - if (!pickingResult || !pickingResult.pickedMesh) { - return +function findParentEntity( + node: T +): { + handleClick(pointerEvent: 'pointerUp' | 'pointerDown', pointerId: number, pickingResult: BABYLON.PickingInfo): void +} | null { + // Find the next entity parent to dispatch the event + let parent: BABYLON.Node = node.parent + + while (parent && !('isDCLEntity' in parent)) { + parent = parent.parent + + // If the element has no parent, stop execution + if (!parent) return null } - if (isMobile()) { - const actionManager = pickingResult.pickedMesh.actionManager - if (!actionManager) { - return - } + return (parent as any) || null +} + +export function interactWithScene(pointerEvent: 'pointerUp' | 'pointerDown', x: number, y: number, pointerId: number) { + const pickingResult = scene.pick(x, y) + + const mesh = pickingResult.pickedMesh + + const entity = mesh && findParentEntity(mesh) - const action = new BABYLON.ActionEvent(pickingResult.pickedMesh, x, y, pickingResult.pickedMesh, e) - actionManager.processTrigger(BABYLON.ActionManager.OnPickDownTrigger, action) + if (entity) { + entity.handleClick(pointerEvent, pointerId, pickingResult) } else { - const eventData: PointerEventInit = { - clientX: x, - clientY: y, - screenX: x, - screenY: y, - detail: e.detail, - button: e.button, - buttons: e.buttons, - pointerId: e.pointerId, - pointerType: e.pointerType + for (let scene of loadedParcelSceneWorkers) { + if (scene.parcelScene instanceof WebGLScene) { + scene.parcelScene.context.sendPointerEvent(pointerEvent, pointerId, null, pickingResult) + } } - - scene.cameraToUseForPointers = scene.activeCamera - scene.simulatePointerDown(pickingResult, eventData) } } @@ -208,77 +203,29 @@ export function enableMouseLock(canvas: HTMLCanvasElement) { canvas.requestPointerLock = canvas.requestPointerLock || canvas['mozRequestPointerLock'] } - window.addEventListener('pointerdown', evt => { - if (hasPointerLock() && !vrHelper.isInVRMode) { - evt.preventDefault() - evt.stopPropagation() - canvas.focus() - interactWithScene(evt, canvas.width / 2, canvas.height / 2) - } - }) - - window.addEventListener('pointerup', evt => { - if (hasPointerLock() && !vrHelper.isInVRMode) { - evt.preventDefault() - evt.stopPropagation() - canvas.focus() - - const pickingResult = scene.pick(canvas.width / 2, canvas.height / 2) - - if (pickingResult && pickingResult.pickedMesh) { - const eventData: PointerEventInit = { - clientX: canvas.width / 2, - clientY: canvas.height / 2, - screenX: canvas.width / 2, - screenY: canvas.height / 2, - detail: evt.detail, - button: evt.button, - buttons: evt.buttons, - pointerId: (evt as any).pointerId, - pointerType: (evt as any).pointerType + scene.onPointerObservable.add(e => { + if (e.type === BABYLON.PointerEventTypes.POINTERDOWN) { + const evt = e.event as PointerEvent + + if (isThirdPersonCamera()) { + canvas.focus() + interactWithScene('pointerDown', evt.offsetX, evt.offsetY, evt.pointerId) + } else { + if (hasPointerLock()) { + canvas.focus() + interactWithScene('pointerDown', canvas.width / 2, canvas.height / 2, evt.pointerId) + } else { + canvas.requestPointerLock() + canvas.focus() } - scene.cameraToUseForPointers = scene.activeCamera - scene.simulatePointerUp(pickingResult, eventData) } - } - }) - - canvas.addEventListener('click', () => { - if (isThirdPersonCamera()) { - return - } - - const preventPointerLock = PointerLock.preventLocking - - if (!preventPointerLock && !hasPointerLock()) { - canvas.requestPointerLock() - canvas.focus() - } - - // Disable locking prevention again (as it was set initially) - PointerLock.preventLocking = false - }) - - scene.onPrePointerObservable.add(evt => { - if (isThirdPersonCamera()) { - return - } - - if (evt.type === BABYLON.PointerEventTypes.POINTERDOWN || evt.type === BABYLON.PointerEventTypes.POINTERUP) { - // regular mouse events doesn't have the `ray` property - evt.skipOnPointerObservable = !evt.ray - } - }) - - document.addEventListener('pointerlockchange', function() { - const isPointerLocked = hasPointerLock() - PointerLock.isLocked = isPointerLocked + } else if (e.type === BABYLON.PointerEventTypes.POINTERUP) { + const evt = e.event as PointerEvent - if (!isPointerLocked) { - vrCamera.detachControl(canvas) - } else { - if (scene.activeCamera === vrCamera) { - vrCamera.attachControl(canvas) + if (isThirdPersonCamera()) { + interactWithScene('pointerUp', evt.offsetX, evt.offsetY, evt.pointerId) + } else if (hasPointerLock()) { + interactWithScene('pointerUp', canvas.width / 2, canvas.height / 2, evt.pointerId) } } }) diff --git a/packages/entryPoints/editor.ts b/packages/entryPoints/editor.ts index 562dc8616..92cd02ff9 100644 --- a/packages/entryPoints/editor.ts +++ b/packages/entryPoints/editor.ts @@ -157,6 +157,7 @@ export namespace editor { arcCamera.beta = Math.PI / 3 arcCamera.radius = DEFAULT_CAMERA_ZOOM } else { + canvas.focus() canvas.requestPointerLock() if (webGlParcelScene) { vrCamera.position.x = webGlParcelScene.worker.position.x + 5 diff --git a/packages/scene-system/scene.system.ts b/packages/scene-system/scene.system.ts index c7c0f4dfe..d84a6193a 100644 --- a/packages/scene-system/scene.system.ts +++ b/packages/scene-system/scene.system.ts @@ -222,27 +222,31 @@ export default class GamekitScene extends Script { /** called after adding a component to the entity or after updating a component */ updateEntityComponent(entityId: string, componentName: string, classId: number, json: string): void { - that.events.push({ - type: 'UpdateEntityComponent', - payload: JSON.stringify({ - entityId, - classId, - name: componentName.replace(componentNameRE, ''), - json - } as UpdateEntityComponentPayload) - }) + if (componentNameRE.test(componentName)) { + that.events.push({ + type: 'UpdateEntityComponent', + payload: JSON.stringify({ + entityId, + classId, + name: componentName.replace(componentNameRE, ''), + json + } as UpdateEntityComponentPayload) + }) + } }, /** called after adding a DisposableComponent to the entity */ attachEntityComponent(entityId: string, componentName: string, id: string): void { - that.events.push({ - type: 'AttachEntityComponent', - payload: JSON.stringify({ - entityId, - name: componentName.replace(componentNameRE, ''), - id - } as AttachEntityComponentPayload) - }) + if (componentNameRE.test(componentName)) { + that.events.push({ + type: 'AttachEntityComponent', + payload: JSON.stringify({ + entityId, + name: componentName.replace(componentNameRE, ''), + id + } as AttachEntityComponentPayload) + }) + } }, /** call after removing a component from the entity */ @@ -252,7 +256,7 @@ export default class GamekitScene extends Script { type: 'ComponentRemoved', payload: JSON.stringify({ entityId, - name: componentName + name: componentName.replace(componentNameRE, '') } as ComponentRemovedPayload) }) } @@ -282,14 +286,16 @@ export default class GamekitScene extends Script { }, componentCreated(id: string, componentName: string, classId: number) { - that.events.push({ - type: 'ComponentCreated', - payload: JSON.stringify({ - id, - classId, - name: componentName - } as ComponentCreatedPayload) - }) + if (componentNameRE.test(componentName)) { + that.events.push({ + type: 'ComponentCreated', + payload: JSON.stringify({ + id, + classId, + name: componentName.replace(componentNameRE, '') + } as ComponentCreatedPayload) + }) + } }, componentDisposed(id: string) { diff --git a/packages/shared/comms/index.ts b/packages/shared/comms/index.ts index 4f83beafb..38d3371a3 100644 --- a/packages/shared/comms/index.ts +++ b/packages/shared/comms/index.ts @@ -24,6 +24,7 @@ import { chatObservable, ChatEvent } from './chat' import { positionObserver } from 'shared/world/positionThings' import { PositionMessage } from './worldcomm_pb' import { log, error as logError } from 'engine/logger' +import { ReadOnlyVector3, ReadOnlyQuaternion } from 'decentraland-ecs/src' const loaderWorkerRaw = require('raw-loader!../../../static/systems/comms.system.js') const loaderWorkerBLOB = new Blob([loaderWorkerRaw]) @@ -231,9 +232,9 @@ class CommunicationServer extends TransportBasedServer { onPositionUpdate( obj: Readonly<{ - position: BABYLON.Vector3 - rotation: BABYLON.Vector3 - quaternion: BABYLON.Quaternion + position: ReadOnlyVector3 + rotation: ReadOnlyVector3 + quaternion: ReadOnlyQuaternion }> ) { this.notify('onPositionUpdate', { diff --git a/packages/shared/types.ts b/packages/shared/types.ts index ee75f7b9f..9591a32da 100644 --- a/packages/shared/types.ts +++ b/packages/shared/types.ts @@ -166,30 +166,6 @@ export interface ILand { mappingsResponse: MappingsResponse } -/** - * This data type defines a two component vector. - */ -export type Vector2Component = { - x: number - y: number -} - -/** - * This data type defines a three component vector. It is used for scaling, positioning and rotations - */ -export type Vector3Component = { - x: number - y: number - z: number -} - -export type QuaternionComponent = { - x: number - y: number - z: number - w: number -} - export type SoundComponent = { /** Distance fading model, default: 'linear' */ distanceModel?: 'linear' | 'inverse' | 'exponential' diff --git a/packages/shared/world/SceneWorker.ts b/packages/shared/world/SceneWorker.ts index 72a5806c8..5f6beab4e 100644 --- a/packages/shared/world/SceneWorker.ts +++ b/packages/shared/world/SceneWorker.ts @@ -1,5 +1,4 @@ import { future } from 'fp-future' -import { Vector3 } from 'babylonjs' import { ScriptingHost } from 'decentraland-rpc/lib/host' import { error } from '../../engine/logger' import { ScriptingTransport } from 'decentraland-rpc/lib/common/json-rpc/types' @@ -7,6 +6,7 @@ import { WebWorkerTransport } from 'decentraland-rpc' import { playerConfigurations } from '../../config' import { EntityAction, EnvironmentData } from 'shared/types' import { EnvironmentAPI } from 'shared/apis/EnvironmentAPI' +import { Vector3, Quaternion, ReadOnlyVector3, ReadOnlyQuaternion } from 'decentraland-ecs/src/decentraland/math' // tslint:disable-next-line:whitespace type EngineAPI = import('../apis/EngineAPI').EngineAPI @@ -40,8 +40,8 @@ export class SceneWorker { public enabled = true public readonly position: Vector3 = new Vector3() - private readonly lastSentPosition = new BABYLON.Vector3(0, 0, 0) - private readonly lastSentRotation = new BABYLON.Quaternion(0, 0, 0, 1) + private readonly lastSentPosition = new Vector3(0, 0, 0) + private readonly lastSentRotation = new Quaternion(0, 0, 0, 1) constructor(public parcelScene: ParcelSceneAPI, transport?: ScriptingTransport) { parcelScene.registerWorker(this) @@ -65,7 +65,7 @@ export class SceneWorker { } sendUserViewMatrix( - obj: Readonly<{ position: BABYLON.Vector3; rotation: BABYLON.Vector3; quaternion: BABYLON.Quaternion }> + obj: Readonly<{ position: ReadOnlyVector3; rotation: ReadOnlyVector3; quaternion: ReadOnlyQuaternion }> ) { if (this.engineAPI && 'positionChanged' in this.engineAPI.subscribedEvents) { if (!this.lastSentPosition.equals(obj.position)) { @@ -93,39 +93,6 @@ export class SceneWorker { } } - sendPointerEvent(evt: BABYLON.PointerInfoPre) { - if (!this.engineAPI) return - if (!evt.ray) return - - if (evt.type === BABYLON.PointerEventTypes.POINTERDOWN && 'pointerDown' in this.engineAPI.subscribedEvents) { - this.engineAPI.sendSubscriptionEvent('pointerDown', { - from: { - x: evt.ray.origin.x - this.position.x, - y: evt.ray.origin.y - this.position.y, - z: evt.ray.origin.z - this.position.z - }, - direction: evt.ray.direction, - length: evt.ray.length, - pointerId: (evt.event as any).pointerId - }) - return - } - - if (evt.type === BABYLON.PointerEventTypes.POINTERUP && 'pointerUp' in this.engineAPI.subscribedEvents) { - this.engineAPI.sendSubscriptionEvent('pointerUp', { - from: { - x: evt.ray.origin.x - this.position.x, - y: evt.ray.origin.y - this.position.y, - z: evt.ray.origin.z - this.position.z - }, - direction: evt.ray.direction, - length: evt.ray.length, - pointerId: (evt.event as any).pointerId - }) - return - } - } - private async startSystem(transport: ScriptingTransport) { const system = await ScriptingHost.fromTransport(transport) diff --git a/packages/shared/world/parcelSceneManager.ts b/packages/shared/world/parcelSceneManager.ts index 5757e86cf..c400abbf1 100644 --- a/packages/shared/world/parcelSceneManager.ts +++ b/packages/shared/world/parcelSceneManager.ts @@ -4,6 +4,7 @@ import { positionObserver } from './positionThings' import { worldToGrid } from '../../atomicHelpers/parcelScenePositions' import { SceneWorker, ParcelSceneAPI } from './SceneWorker' import { LoadableParcelScene, EnvironmentData, ILand, ILandToLoadableParcelScene } from '../types' +import { Vector2 } from 'decentraland-ecs/src/decentraland/math' export type EnableParcelSceneLoadingOptions = { parcelSceneClass: { @@ -29,7 +30,7 @@ export function getParcelById(id: string) { export async function enableParcelSceneLoading(network: ETHEREUM_NETWORK, options: EnableParcelSceneLoadingOptions) { const ret = await initParcelSceneWorker(network) - const position = BABYLON.Vector2.Zero() + const position = Vector2.Zero() function setParcelScenes(parcelScenes: ILand[]) { const completeListOfParcelsThatShouldBeLoaded = parcelScenes.map($ => $.mappingsResponse.root_cid) diff --git a/packages/shared/world/positionThings.ts b/packages/shared/world/positionThings.ts index 480eabb22..a553b5fb8 100644 --- a/packages/shared/world/positionThings.ts +++ b/packages/shared/world/positionThings.ts @@ -1,17 +1,18 @@ import { worldToGrid, gridToWorld, parseParcelPosition } from 'atomicHelpers/parcelScenePositions' -import * as BABYLON from 'babylonjs' import * as qs from 'query-string' import { ILand } from 'shared/types' +import { Vector3, ReadOnlyVector3, ReadOnlyQuaternion, Vector2 } from 'decentraland-ecs/src/decentraland/math' +import { Observable } from 'babylonjs' -export const positionObserver = new BABYLON.Observable< +export const positionObserver = new Observable< Readonly<{ - position: BABYLON.Vector3 - rotation: BABYLON.Vector3 - quaternion: BABYLON.Quaternion + position: ReadOnlyVector3 + rotation: ReadOnlyVector3 + quaternion: ReadOnlyQuaternion }> >() -export const lastPlayerPosition = new BABYLON.Vector3() +export const lastPlayerPosition = new Vector3() positionObserver.add(event => { lastPlayerPosition.copyFrom(event.position) @@ -21,9 +22,9 @@ export function initializeUrlPositionObserver() { let lastTime: number = performance.now() let previousPosition = null - const gridPosition = BABYLON.Vector2.Zero() + const gridPosition = Vector2.Zero() - function updateUrlPosition(cameraVector: BABYLON.Vector3) { + function updateUrlPosition(cameraVector: ReadOnlyVector3) { // Update position in URI every second if (performance.now() - lastTime > 1000) { worldToGrid(cameraVector, gridPosition) diff --git a/packages/unity-interface/dcl.ts b/packages/unity-interface/dcl.ts index 3eccece3d..0fbe318a8 100644 --- a/packages/unity-interface/dcl.ts +++ b/packages/unity-interface/dcl.ts @@ -4,27 +4,20 @@ import { initShared } from '../shared' import { DevTools } from '../shared/apis/DevTools' import { ILogger, createLogger } from '../shared/logger' import { positionObserver, lastPlayerPosition } from '../shared/world/positionThings' -import { Vector3, Quaternion } from 'babylonjs' import { enableParcelSceneLoading, getParcelById } from '../shared/world/parcelSceneManager' import { IEventNames, IEvents } from '../decentraland-ecs/src/decentraland/Types' -import { - LoadableParcelScene, - Vector3Component, - QuaternionComponent, - EntityAction, - EnvironmentData, - ILandToLoadableParcelScene -} from '../shared/types' +import { LoadableParcelScene, EntityAction, EnvironmentData, ILandToLoadableParcelScene } from '../shared/types' import { SceneWorker, ParcelSceneAPI } from '../shared/world/SceneWorker' import { EventDispatcher } from 'decentraland-rpc/lib/common/core/EventDispatcher' import { ParcelIdentity } from '../shared/apis/ParcelIdentity' +import { Vector3, Quaternion, ReadOnlyVector3, ReadOnlyQuaternion } from '../decentraland-ecs/src/decentraland/math' let gameInstance: GameInstance = null const positionEvent = { position: Vector3.Zero(), - quaternion: Quaternion.Identity(), + quaternion: Quaternion.Identity, rotation: Vector3.Zero() } @@ -32,10 +25,10 @@ const positionEvent = { const browserInterface = { /** Triggered when the camera moves */ - ReportPosition(data: { position: Vector3Component; rotation: QuaternionComponent }) { + ReportPosition(data: { position: ReadOnlyVector3; rotation: ReadOnlyQuaternion }) { positionEvent.position.set(data.position.x, data.position.y, data.position.z) positionEvent.quaternion.set(data.rotation.x, data.rotation.y, data.rotation.z, data.rotation.w) - positionEvent.quaternion.toEulerAnglesToRef(positionEvent.rotation) + positionEvent.rotation.copyFrom(positionEvent.quaternion.eulerAngles) positionObserver.notifyObservers(positionEvent) }, diff --git a/public/ecs-parcels/-200.2-sound-test/game.ts b/public/ecs-parcels/-200.2-sound-test/game.ts index 7ffe3b0f5..8333199f9 100644 --- a/public/ecs-parcels/-200.2-sound-test/game.ts +++ b/public/ecs-parcels/-200.2-sound-test/game.ts @@ -10,7 +10,7 @@ ) cube.getOrCreate(BoxShape) cube.set( - new OnClick(() => { + new OnPointerDown(() => { cube.get(Transform).position.set(Math.random() * 8 + 1, Math.random() * 8 + 1, Math.random() * 8 + 1) }) ) @@ -38,7 +38,7 @@ cube.getOrCreate(BoxShape) cube.set( - new OnClick(() => { + new OnPointerDown(() => { source.playOnce() }) ) diff --git a/public/ecs-parcels/-200.3-animation-clip/game.ts b/public/ecs-parcels/-200.3-animation-clip/game.ts index d57661707..9fe692539 100644 --- a/public/ecs-parcels/-200.3-animation-clip/game.ts +++ b/public/ecs-parcels/-200.3-animation-clip/game.ts @@ -20,7 +20,7 @@ cube.set( ) cube.getOrCreate(BoxShape) cube.set( - new OnClick(() => { + new OnPointerDown(() => { executeTask(async () => { // 1 await pauseSound() }) diff --git a/public/ecs-parcels/-200.4-ethereum-controller/game.ts b/public/ecs-parcels/-200.4-ethereum-controller/game.ts index 310e2e660..39d22549d 100644 --- a/public/ecs-parcels/-200.4-ethereum-controller/game.ts +++ b/public/ecs-parcels/-200.4-ethereum-controller/game.ts @@ -418,7 +418,7 @@ text.billboard = true text.isPickable = true cube.set(text) cube.set( - new OnClick(() => { + new OnPointerDown(() => { executeTask(async () => { const provider = await getProvider() const requestManager = new EthConnect.RequestManager(provider) diff --git a/public/local-ipfs/mappings b/public/local-ipfs/mappings index 782cf2f50..1313a8bac 100644 --- a/public/local-ipfs/mappings +++ b/public/local-ipfs/mappings @@ -2926,6 +2926,29 @@ } ] }, + { + "publisher": "0x0f5d2fb29fb7d3cfee444a200298f468908cc942", + "parcel_id": "-101,100", + "root_cid": "Qm66rG3pLQ4YnQSMabGkdu1xFGk9zvU4JM6fR8UktcEjWJxHCAtaeYZWEUocpBDHFYXouHhTL6NhqKK4UeeXKQ9HLw", + "contents": [ + { + "file": "game.js", + "hash": "Qm5mtn6KMUZSesY35nF5nEAr1vLU31KsjaBzAZGRVgxHV6gZVPaA4CBenAe8kDMkrHqbSRNpBbdXtTCYpirDfwexS3" + }, + { + "file": "game.ts", + "hash": "QmGDFqsuTXt9gkizvaf4LkfSyDb1TNmNgQiTy2N47ZcsFWVYZnxeoEnwvc5g8p5BMrQzr3J9UzL24AqYfePMg5XHc" + }, + { + "file": "scene.json", + "hash": "Qm4LjKkE8j5mnnFrzKQ8uMyhNbgUeXgJBzAejbGbbazTg74rMDaF14uSAGXKvgPXpHafBLFooJVAVGuxC3LmhxF8yR" + }, + { + "file": "tsconfig.json", + "hash": "Qm2HzKY6aDW4Kv647VQfwFg7Ex5VTge85U5DQur8dTkLctGSrUT5PwsJLXjuXiYEPxbCpX2V1vn5BFPo6G1puM3R9f" + } + ] + }, { "publisher": "0x0f5d2fb29fb7d3cfee444a200298f468908cc942", "parcel_id": "-102,100", @@ -4873,6 +4896,404 @@ } ] }, + { + "publisher": "0x0f5d2fb29fb7d3cfee444a200298f468908cc942", + "parcel_id": "200,12", + "root_cid": "Qm3DNCTTK9LKwfkNY9t7JHt7QB73gXSNrddWT2LVH2ZhaomUgB65ZtCr3aCvPk1VMXMQTo72VDbG7w3f952ai32YUD", + "contents": [ + { + "file": "game.js", + "hash": "Qm2wG5bgKrivuY3mZvtdeNc82t3DQeQ6TVdNkyRYYPWhowqidwvF6q3YKxPhfbTQ3bHbNuVXXEwQc3gjPdUUFCf8Ht" + }, + { + "file": "game.ts", + "hash": "Qm5tTFsqfB98eBRgHT64e69j6o7nV3cFHs8KJzo5EQ3Av2G6sxk79wB2zrCrWpSbta8ocNdSgQ2hQut9iYd7meZbDP" + }, + { + "file": "models/base.mtl", + "hash": "Qm45pVuS9cNn7WTXWSvcZvxGJU2PgwUC3U8PL511F6xTdVyKBLnMRYHsJDjaqcdmbJPaxZhHf6LpStnKQGg62y4fes" + }, + { + "file": "models/base.obj", + "hash": "Qm3a8AX2mcprR8PF5BGqXRdMFn4zgA6YZ62DSLQRF6ypHyXyWfTNcEDaGVQNXGX184QFUBooLvkTwRZgVuPzESfqC7" + }, + { + "file": "models/button.mtl", + "hash": "Qm2ADErrMFrQujPc4U1KAwEXxEpwAggaANNohKHucJD74DFPcxbrjYn21gSqPiiKen1nQdGjvQYgBsQzhCnNPM7Pfb" + }, + { + "file": "models/button.obj", + "hash": "Qm2hehFoK7qizwUGieVTacnpEy8AzHbecfdjqUedrkhd9TWtuYZtHjsYsE28viZqaWHSDrAXAYMESkjau8D87MDzdF" + }, + { + "file": "models/croc0_001.mtl", + "hash": "Qm1AXDboT3JFVFLAejCGN87ahShPJxX6igquB9ud2Z3VEaTGPRM9pKoQvfCF1sRkdh9Z19x1Pp91hsDd72eKMdkH9" + }, + { + "file": "models/croc0_001.obj", + "hash": "Qm2c7uew3EKFC7SZ8iXEWwmANMBXbmTWzybSDysoBqMDQ3Ugfz4MuNkoYzHjTYiiYqy8tw6V8MRgWunCFVF1HDgKCY" + }, + { + "file": "models/croc0_002.mtl", + "hash": "Qm57gLejWY9qNxjXR1TbCcsYhYLKi8WPPfiyoADG2BketYL3ukmw15NZSF7Nj6dQEJkyAZ1YjzcoPMg84JzicrxFPX" + }, + { + "file": "models/croc0_002.obj", + "hash": "Qm49cFmkmLuUzdCQXzy1oGSsEfFYDLnEMC1xW2JzMjoN7osANYZacCfxhTMWZiFvCdAqyRgG3tSRCi6Q1Kf2A9vc7G" + }, + { + "file": "models/croc0_003.mtl", + "hash": "Qm43x7SqrXTcS3Ny6DrmKPXPj9UQa6jEYj2hHBeFMx4qY4gnEdM7YRp3EMCmqcgAWmpCH1fapYiizQxKpuLMDoe9Ug" + }, + { + "file": "models/croc0_003.obj", + "hash": "Qm3p5f8Br3b6CgcBtkLECfTg4DcdrdMYMkyRPLu3DU263SF8AbdX8Q2P2isXUy642qu6UTbz2fLT5kqrMiUzm7wisw" + }, + { + "file": "models/croc0_004.mtl", + "hash": "Qm3ZiHNY3gx955J988WMt54pGAySsdwW3hBQR4PzxyQzAfvAgfuzbRzZThZkgjbKCaUog9Cz9ocMgTRbFkSykpXJFW" + }, + { + "file": "models/croc0_004.obj", + "hash": "Qm3kuaqnZKAjvmxJ6Y1SdQiEebqevygopf7QrFpXyLeWbhfaYNmE1mk9h2KyPZxMqfs9LPVnPw7CtUaSxBDMcBZsgg" + }, + { + "file": "models/croc0.mtl", + "hash": "Qm4ocHJnLt5T5GpMGagDqiddtg7GwdS4eqMchWgWXZGxskuSdPu4Mm28whc1hBrGmmFutF6H8yj2RtT4WbQrc9AXZS" + }, + { + "file": "models/croc0.obj", + "hash": "Qm3JrctcLx2p3DkRsks8eNpp2h7RFai1FweU6bJgDQWuppnrcCa1VXgWRcp1sm4o9LYy6n85Q62VCu3CbS6P6Ntxz7" + }, + { + "file": "models/game_over.mtl", + "hash": "Qm46QurQ7r4QREnPDgySENKiaqT72YBdaGYGUDS6HYKb9ds6FNEGc5cAc4MPgB6Hoc4cq3pZvbvjuWre9jEcB9r6sF" + }, + { + "file": "models/game_over.obj", + "hash": "Qm32Sw3TEjLsyop99nEzLBHcRpKQumnQAZzPREbst5DZiP4ta1KyuLNFbDysEpctZbEkEXnQPTCAUKvxU3BhK1chiR" + }, + { + "file": "models/instructions.mtl", + "hash": "Qm2xLaeKRegohbU6H55uoAxgiiBAfGhPvkrYTBQCm5UVFEwyucZyfCM8XnFWpRqViNQjDjJmudNmSLcAkDTLLsYuBT" + }, + { + "file": "models/instructions.obj", + "hash": "Qm59LfpPiRM62jXwjh3XYSCTGdbd6obSjZM51mqpos89mJSZ9wNnJnba5eJQXuVXMfTyUwtMkJ9aeXwVZkmuWkL7vq" + }, + { + "file": "models/press_button.mtl", + "hash": "Qm5o4B4yTkv2eFUEK2jLQCC8Bdves2yTgG6ARQX8fZgRpCnSTQq1WgjEapijJaTnPKQJfqk6kJPNQQMKRzmGw1Fs5p" + }, + { + "file": "models/press_button.obj", + "hash": "Qm4SgbJLv2rFxDky3gzhJ2z14xpiNSsLKrE9NBkwgUcjUtH2NaBY4ViGKZ1iTyXUPnZGrVBQTvhLcp2z8Ai7BBto3Z" + }, + { + "file": "models/separator_001.mtl", + "hash": "Qm3dS8nQzZZGzxVKiMgYDGmbgtL5UrZmAfDZxSvyVhJyMkszah3wiscQmsGFdqkZTUedyCVVGiyLu9YCJg1LAVbEQX" + }, + { + "file": "models/separator_001.obj", + "hash": "Qm5bfmaRWEEWHJBHUdy6PcUmqPDNdqV6ypsZrhEuUwt8KtNwKXz6pRUpwb9H8QzBWrfVXD4NYiBbrenWeGpL2F7AG1" + }, + { + "file": "models/separator_002.mtl", + "hash": "Qm4rmEx5RUsQkTkpwtRi7a4ZD3yE9tU9MeuW1GWPTDRKdLi2ASwXnadDApWCppy8TvxEUosQYJrajECtGZgZk3CLDb" + }, + { + "file": "models/separator_002.obj", + "hash": "Qm26MoUcXEShLoJarvw3cPgyap9yb6dHoMQJrjneVXE6nvadWN9rG9ybbyZkgwj2He2ki23mhWyhSVo6US5vyYr2WQ" + }, + { + "file": "models/separator_003.mtl", + "hash": "Qmd3ysWP2J1gLEnAGNrquAj1ySJgwtWFTowRENcZMa7GgFGWhUtBz1GKbXbaskbWAQsA7aW6LFPWFb2zNrKdEz9w1" + }, + { + "file": "models/separator_003.obj", + "hash": "Qm3PoSWMxRw3BZYF4K26CGTcevQfUKbZzWAvrGLu9psnmkgBk5VhHcXghQjzDjCkf3NbW8P9NbqnK9ihnQbmAHv4wi" + }, + { + "file": "models/separator_004.mtl", + "hash": "QmVxUzuSzqFjdBgvFJ3573cUAo9Vfp7P67EZSaU4Uveap6jYi73pdwPCh5DLYDTjA2zYXX6mrBQ2gQxgjDrRjYMa6" + }, + { + "file": "models/separator_004.obj", + "hash": "Qm5pfw2H3DhAHHEA6GACiH4CMczXXECHSw5gWVSpcdEA6z1GWC9dJNyXYoHFMeTeFnQ8NUzwMD1hJBLeKCBW55NXpm" + }, + { + "file": "models/separator_005.mtl", + "hash": "Qm45ZBLDd2pMYzcnRM6jXzjKF7XSRKKZWMmtDviboLy1oaxW56Xy42ckisiMs7998VUm6CF3sxYGUf4MWTbYrjmtPT" + }, + { + "file": "models/separator_005.obj", + "hash": "Qm5yzGvP9cvi44FoM2ofngxEZeePscqEQasq4jzc7jrJ5sdmFffz18c9juDjHPR7vMcJxrkikak4o7Wmqksh2C6jti" + }, + { + "file": "models/separator.mtl", + "hash": "Qm2Zo254jAsyxrkUNF7c8oKgTMMrRBag5Za4VB8UJK4UkgrbHrUACbHXfNTJDGPiHnVtNwJrxJgnFp4ARtqASWdWyZ" + }, + { + "file": "models/separator.obj", + "hash": "Qm2akcRp7vyTu5JvwWAW6fbELSZR1ieqjZD4y3yKXbdMkR6H85yo2MKFj5LNMaDB1aXyKfUyzGowmWxnpJ4tsjMWq1" + }, + { + "file": "models/side.mtl", + "hash": "Qm3AVWQWMkPV3hnPCHLC9vgq5YrK8fNfuPz3Hp52pcu4oDBNHrRhJqsXs7KymjKxgiTPLV6ojgetW1FP4dopL1zucP" + }, + { + "file": "models/side.obj", + "hash": "Qm2MJUVTE8sCiy9A19eubrM218bizVJpGkvW6A2iwYLzFcSQjg2GmYTNmbhsjW1TrCyQ9gwX535TTLA3DE74Xy2XZ5" + }, + { + "file": "models/side2.mtl", + "hash": "Qm57N1BSkfaaQfasksMrHcM5hQ1JVMm65GdyhkpAxE84XQiBmH4Eza27fUGU9ATMiaGFomzuMCYSh7nqobW2h5proo" + }, + { + "file": "models/side2.obj", + "hash": "Qm4NZQC8upcsSfvwq5T8GGNbVBoMUHXiNeR1rZ99nk1V6Xe33eNnZmgS5Es4xT4N9BdptRAKtaowYC6gQNqgxkLBY6" + }, + { + "file": "models/subtitle.mtl", + "hash": "Qm5M5m4vcLaFa7acmuP3RKGVYb8HMtS6sQgRbuvyBWzzSa3G3hoR1jn6wNnbEycw1dXhjXPAVNGgbosEjJ22KrTE11" + }, + { + "file": "models/subtitle.obj", + "hash": "Qm4n5f43z3stKWJaW1URPGrz6LLVSSqWrpUkEncLC6a3sDjvg65ebo7VToncA5gq7tji9UNqZcooGWimM71rpYox8g" + }, + { + "file": "models/title.mtl", + "hash": "Qm2F6TRog1iUDiWUFahkmyFFnPDqpnAwWFZhbsQXDrGbEm7jRHig6NcW1EWcvqTozbipN5oPWQutsUrztuDV4Vdk4K" + }, + { + "file": "models/title.obj", + "hash": "Qm5UbCVRygnWGANKtpLFc1vfDmhV2vit8ejcihyCtkyY43g7Yu5Y3F4iUYSqXEGChyBpZKiCKHL6P8gsumfooZijJn" + }, + { + "file": "scene.json", + "hash": "Qm62HYb2PKMsKLdjjJQzwKhh4RWxMqscVGLbpbANtL5Q6TQi1B9HjSHZWoegSimnfnypKE2V7t4FQmqaZMrpjViQfY" + }, + { + "file": "sounds/button.ogg", + "hash": "Qm598GFgLS8nuq3tRHb5X3q6X8nU4WBEm2Bfk1QMkDcNb8Aheto3RuQH9qAkeHyQAQMkSgjySfiAWvCi1BmHDYwWs8" + }, + { + "file": "sounds/carnivalrides.ogg", + "hash": "QmptVHbumccCcz9DT3jTcPwLjYVFhz2VswndnnKbFjHF4TJMv2dk5yBtj5wZxhs1zso5XQpw31o4VwGXmzYY4xwXS" + }, + { + "file": "sounds/gameover.ogg", + "hash": "Qm3ENS3wEPSFwp9WQZQZnoafqctJqXZnNmTV2XZ3Msb229X6c6hgXwsBC7orKkPYYdumPyLK4geqva1tPA96H1um91" + }, + { + "file": "sounds/win.ogg", + "hash": "Qm3z2hkHDvEXXTwbs9HWeMA7yZHcszqwW26jUGPXa6rcvLPRQy8iqLQJUPiNjSd3t3BuGjCLpYPAYJcQcGmbh9NR7X" + }, + { + "file": "tsconfig.json", + "hash": "Qm3qZMg6Nj1ZBgcavAHR73jg2RqH9UEss9M8frdoybzpDVhgKwYuHWW9snjzCuihivVyjsYRdrRibu3aiAXCke8hzU" + } + ] + }, + { + "publisher": "0x0f5d2fb29fb7d3cfee444a200298f468908cc942", + "parcel_id": "200,13", + "root_cid": "Qm3DNCTTK9LKwfkNY9t7JHt7QB73gXSNrddWT2LVH2ZhaomUgB65ZtCr3aCvPk1VMXMQTo72VDbG7w3f952ai32YUD", + "contents": [ + { + "file": "game.js", + "hash": "Qm2wG5bgKrivuY3mZvtdeNc82t3DQeQ6TVdNkyRYYPWhowqidwvF6q3YKxPhfbTQ3bHbNuVXXEwQc3gjPdUUFCf8Ht" + }, + { + "file": "game.ts", + "hash": "Qm5tTFsqfB98eBRgHT64e69j6o7nV3cFHs8KJzo5EQ3Av2G6sxk79wB2zrCrWpSbta8ocNdSgQ2hQut9iYd7meZbDP" + }, + { + "file": "models/base.mtl", + "hash": "Qm45pVuS9cNn7WTXWSvcZvxGJU2PgwUC3U8PL511F6xTdVyKBLnMRYHsJDjaqcdmbJPaxZhHf6LpStnKQGg62y4fes" + }, + { + "file": "models/base.obj", + "hash": "Qm3a8AX2mcprR8PF5BGqXRdMFn4zgA6YZ62DSLQRF6ypHyXyWfTNcEDaGVQNXGX184QFUBooLvkTwRZgVuPzESfqC7" + }, + { + "file": "models/button.mtl", + "hash": "Qm2ADErrMFrQujPc4U1KAwEXxEpwAggaANNohKHucJD74DFPcxbrjYn21gSqPiiKen1nQdGjvQYgBsQzhCnNPM7Pfb" + }, + { + "file": "models/button.obj", + "hash": "Qm2hehFoK7qizwUGieVTacnpEy8AzHbecfdjqUedrkhd9TWtuYZtHjsYsE28viZqaWHSDrAXAYMESkjau8D87MDzdF" + }, + { + "file": "models/croc0_001.mtl", + "hash": "Qm1AXDboT3JFVFLAejCGN87ahShPJxX6igquB9ud2Z3VEaTGPRM9pKoQvfCF1sRkdh9Z19x1Pp91hsDd72eKMdkH9" + }, + { + "file": "models/croc0_001.obj", + "hash": "Qm2c7uew3EKFC7SZ8iXEWwmANMBXbmTWzybSDysoBqMDQ3Ugfz4MuNkoYzHjTYiiYqy8tw6V8MRgWunCFVF1HDgKCY" + }, + { + "file": "models/croc0_002.mtl", + "hash": "Qm57gLejWY9qNxjXR1TbCcsYhYLKi8WPPfiyoADG2BketYL3ukmw15NZSF7Nj6dQEJkyAZ1YjzcoPMg84JzicrxFPX" + }, + { + "file": "models/croc0_002.obj", + "hash": "Qm49cFmkmLuUzdCQXzy1oGSsEfFYDLnEMC1xW2JzMjoN7osANYZacCfxhTMWZiFvCdAqyRgG3tSRCi6Q1Kf2A9vc7G" + }, + { + "file": "models/croc0_003.mtl", + "hash": "Qm43x7SqrXTcS3Ny6DrmKPXPj9UQa6jEYj2hHBeFMx4qY4gnEdM7YRp3EMCmqcgAWmpCH1fapYiizQxKpuLMDoe9Ug" + }, + { + "file": "models/croc0_003.obj", + "hash": "Qm3p5f8Br3b6CgcBtkLECfTg4DcdrdMYMkyRPLu3DU263SF8AbdX8Q2P2isXUy642qu6UTbz2fLT5kqrMiUzm7wisw" + }, + { + "file": "models/croc0_004.mtl", + "hash": "Qm3ZiHNY3gx955J988WMt54pGAySsdwW3hBQR4PzxyQzAfvAgfuzbRzZThZkgjbKCaUog9Cz9ocMgTRbFkSykpXJFW" + }, + { + "file": "models/croc0_004.obj", + "hash": "Qm3kuaqnZKAjvmxJ6Y1SdQiEebqevygopf7QrFpXyLeWbhfaYNmE1mk9h2KyPZxMqfs9LPVnPw7CtUaSxBDMcBZsgg" + }, + { + "file": "models/croc0.mtl", + "hash": "Qm4ocHJnLt5T5GpMGagDqiddtg7GwdS4eqMchWgWXZGxskuSdPu4Mm28whc1hBrGmmFutF6H8yj2RtT4WbQrc9AXZS" + }, + { + "file": "models/croc0.obj", + "hash": "Qm3JrctcLx2p3DkRsks8eNpp2h7RFai1FweU6bJgDQWuppnrcCa1VXgWRcp1sm4o9LYy6n85Q62VCu3CbS6P6Ntxz7" + }, + { + "file": "models/game_over.mtl", + "hash": "Qm46QurQ7r4QREnPDgySENKiaqT72YBdaGYGUDS6HYKb9ds6FNEGc5cAc4MPgB6Hoc4cq3pZvbvjuWre9jEcB9r6sF" + }, + { + "file": "models/game_over.obj", + "hash": "Qm32Sw3TEjLsyop99nEzLBHcRpKQumnQAZzPREbst5DZiP4ta1KyuLNFbDysEpctZbEkEXnQPTCAUKvxU3BhK1chiR" + }, + { + "file": "models/instructions.mtl", + "hash": "Qm2xLaeKRegohbU6H55uoAxgiiBAfGhPvkrYTBQCm5UVFEwyucZyfCM8XnFWpRqViNQjDjJmudNmSLcAkDTLLsYuBT" + }, + { + "file": "models/instructions.obj", + "hash": "Qm59LfpPiRM62jXwjh3XYSCTGdbd6obSjZM51mqpos89mJSZ9wNnJnba5eJQXuVXMfTyUwtMkJ9aeXwVZkmuWkL7vq" + }, + { + "file": "models/press_button.mtl", + "hash": "Qm5o4B4yTkv2eFUEK2jLQCC8Bdves2yTgG6ARQX8fZgRpCnSTQq1WgjEapijJaTnPKQJfqk6kJPNQQMKRzmGw1Fs5p" + }, + { + "file": "models/press_button.obj", + "hash": "Qm4SgbJLv2rFxDky3gzhJ2z14xpiNSsLKrE9NBkwgUcjUtH2NaBY4ViGKZ1iTyXUPnZGrVBQTvhLcp2z8Ai7BBto3Z" + }, + { + "file": "models/separator_001.mtl", + "hash": "Qm3dS8nQzZZGzxVKiMgYDGmbgtL5UrZmAfDZxSvyVhJyMkszah3wiscQmsGFdqkZTUedyCVVGiyLu9YCJg1LAVbEQX" + }, + { + "file": "models/separator_001.obj", + "hash": "Qm5bfmaRWEEWHJBHUdy6PcUmqPDNdqV6ypsZrhEuUwt8KtNwKXz6pRUpwb9H8QzBWrfVXD4NYiBbrenWeGpL2F7AG1" + }, + { + "file": "models/separator_002.mtl", + "hash": "Qm4rmEx5RUsQkTkpwtRi7a4ZD3yE9tU9MeuW1GWPTDRKdLi2ASwXnadDApWCppy8TvxEUosQYJrajECtGZgZk3CLDb" + }, + { + "file": "models/separator_002.obj", + "hash": "Qm26MoUcXEShLoJarvw3cPgyap9yb6dHoMQJrjneVXE6nvadWN9rG9ybbyZkgwj2He2ki23mhWyhSVo6US5vyYr2WQ" + }, + { + "file": "models/separator_003.mtl", + "hash": "Qmd3ysWP2J1gLEnAGNrquAj1ySJgwtWFTowRENcZMa7GgFGWhUtBz1GKbXbaskbWAQsA7aW6LFPWFb2zNrKdEz9w1" + }, + { + "file": "models/separator_003.obj", + "hash": "Qm3PoSWMxRw3BZYF4K26CGTcevQfUKbZzWAvrGLu9psnmkgBk5VhHcXghQjzDjCkf3NbW8P9NbqnK9ihnQbmAHv4wi" + }, + { + "file": "models/separator_004.mtl", + "hash": "QmVxUzuSzqFjdBgvFJ3573cUAo9Vfp7P67EZSaU4Uveap6jYi73pdwPCh5DLYDTjA2zYXX6mrBQ2gQxgjDrRjYMa6" + }, + { + "file": "models/separator_004.obj", + "hash": "Qm5pfw2H3DhAHHEA6GACiH4CMczXXECHSw5gWVSpcdEA6z1GWC9dJNyXYoHFMeTeFnQ8NUzwMD1hJBLeKCBW55NXpm" + }, + { + "file": "models/separator_005.mtl", + "hash": "Qm45ZBLDd2pMYzcnRM6jXzjKF7XSRKKZWMmtDviboLy1oaxW56Xy42ckisiMs7998VUm6CF3sxYGUf4MWTbYrjmtPT" + }, + { + "file": "models/separator_005.obj", + "hash": "Qm5yzGvP9cvi44FoM2ofngxEZeePscqEQasq4jzc7jrJ5sdmFffz18c9juDjHPR7vMcJxrkikak4o7Wmqksh2C6jti" + }, + { + "file": "models/separator.mtl", + "hash": "Qm2Zo254jAsyxrkUNF7c8oKgTMMrRBag5Za4VB8UJK4UkgrbHrUACbHXfNTJDGPiHnVtNwJrxJgnFp4ARtqASWdWyZ" + }, + { + "file": "models/separator.obj", + "hash": "Qm2akcRp7vyTu5JvwWAW6fbELSZR1ieqjZD4y3yKXbdMkR6H85yo2MKFj5LNMaDB1aXyKfUyzGowmWxnpJ4tsjMWq1" + }, + { + "file": "models/side.mtl", + "hash": "Qm3AVWQWMkPV3hnPCHLC9vgq5YrK8fNfuPz3Hp52pcu4oDBNHrRhJqsXs7KymjKxgiTPLV6ojgetW1FP4dopL1zucP" + }, + { + "file": "models/side.obj", + "hash": "Qm2MJUVTE8sCiy9A19eubrM218bizVJpGkvW6A2iwYLzFcSQjg2GmYTNmbhsjW1TrCyQ9gwX535TTLA3DE74Xy2XZ5" + }, + { + "file": "models/side2.mtl", + "hash": "Qm57N1BSkfaaQfasksMrHcM5hQ1JVMm65GdyhkpAxE84XQiBmH4Eza27fUGU9ATMiaGFomzuMCYSh7nqobW2h5proo" + }, + { + "file": "models/side2.obj", + "hash": "Qm4NZQC8upcsSfvwq5T8GGNbVBoMUHXiNeR1rZ99nk1V6Xe33eNnZmgS5Es4xT4N9BdptRAKtaowYC6gQNqgxkLBY6" + }, + { + "file": "models/subtitle.mtl", + "hash": "Qm5M5m4vcLaFa7acmuP3RKGVYb8HMtS6sQgRbuvyBWzzSa3G3hoR1jn6wNnbEycw1dXhjXPAVNGgbosEjJ22KrTE11" + }, + { + "file": "models/subtitle.obj", + "hash": "Qm4n5f43z3stKWJaW1URPGrz6LLVSSqWrpUkEncLC6a3sDjvg65ebo7VToncA5gq7tji9UNqZcooGWimM71rpYox8g" + }, + { + "file": "models/title.mtl", + "hash": "Qm2F6TRog1iUDiWUFahkmyFFnPDqpnAwWFZhbsQXDrGbEm7jRHig6NcW1EWcvqTozbipN5oPWQutsUrztuDV4Vdk4K" + }, + { + "file": "models/title.obj", + "hash": "Qm5UbCVRygnWGANKtpLFc1vfDmhV2vit8ejcihyCtkyY43g7Yu5Y3F4iUYSqXEGChyBpZKiCKHL6P8gsumfooZijJn" + }, + { + "file": "scene.json", + "hash": "Qm62HYb2PKMsKLdjjJQzwKhh4RWxMqscVGLbpbANtL5Q6TQi1B9HjSHZWoegSimnfnypKE2V7t4FQmqaZMrpjViQfY" + }, + { + "file": "sounds/button.ogg", + "hash": "Qm598GFgLS8nuq3tRHb5X3q6X8nU4WBEm2Bfk1QMkDcNb8Aheto3RuQH9qAkeHyQAQMkSgjySfiAWvCi1BmHDYwWs8" + }, + { + "file": "sounds/carnivalrides.ogg", + "hash": "QmptVHbumccCcz9DT3jTcPwLjYVFhz2VswndnnKbFjHF4TJMv2dk5yBtj5wZxhs1zso5XQpw31o4VwGXmzYY4xwXS" + }, + { + "file": "sounds/gameover.ogg", + "hash": "Qm3ENS3wEPSFwp9WQZQZnoafqctJqXZnNmTV2XZ3Msb229X6c6hgXwsBC7orKkPYYdumPyLK4geqva1tPA96H1um91" + }, + { + "file": "sounds/win.ogg", + "hash": "Qm3z2hkHDvEXXTwbs9HWeMA7yZHcszqwW26jUGPXa6rcvLPRQy8iqLQJUPiNjSd3t3BuGjCLpYPAYJcQcGmbh9NR7X" + }, + { + "file": "tsconfig.json", + "hash": "Qm3qZMg6Nj1ZBgcavAHR73jg2RqH9UEss9M8frdoybzpDVhgKwYuHWW9snjzCuihivVyjsYRdrRibu3aiAXCke8hzU" + } + ] + }, { "publisher": "0x0f5d2fb29fb7d3cfee444a200298f468908cc942", "parcel_id": "200,100", diff --git a/public/test-parcels/-1.49.interactions/game.ts b/public/test-parcels/-1.49.interactions/game.ts index 462ba0222..c767245cf 100644 --- a/public/test-parcels/-1.49.interactions/game.ts +++ b/public/test-parcels/-1.49.interactions/game.ts @@ -1,4 +1,4 @@ -import { BoxShape, Transform, Material, engine, Entity, Vector3, Color3, OnClick } from 'decentraland-ecs/src' +import { BoxShape, Transform, Material, engine, Entity, Vector3, Color3, OnPointerDown } from 'decentraland-ecs/src' const c1 = Color3.FromHexString('#ff0000') const c2 = Color3.FromHexString('#00ffFF') @@ -17,7 +17,7 @@ ent.set(mat) ent.set(new BoxShape()) ent.set( - new OnClick(() => { + new OnPointerDown(() => { mat.albedoColor = mat.albedoColor && mat.albedoColor.toHexString() === '#ff0000' ? c2 : c1 }) ) diff --git a/public/test-parcels/-100.100.gamekit-cube/game.ts b/public/test-parcels/-100.100.gamekit-cube/game.ts index 977492707..5b76195fa 100644 --- a/public/test-parcels/-100.100.gamekit-cube/game.ts +++ b/public/test-parcels/-100.100.gamekit-cube/game.ts @@ -1,4 +1,4 @@ -import { Transform, engine, Entity, BoxShape, OnClick, ISystem, log } from 'decentraland-ecs' +import { Transform, engine, Entity, BoxShape, ISystem, log, OnPointerDown } from 'decentraland-ecs/src' export class RotatorSystem implements ISystem { group = engine.getComponentGroup(Transform) @@ -23,7 +23,8 @@ cube.get(Transform).position.set(5, 1, 5) cube.set(new BoxShape()) cube.set( - new OnClick(_ => { + new OnPointerDown(evt => { + log('cubeClick', evt) if (cube.has(Transform)) { // this will place the entity at the scene origin (out of bounds) cube.remove(Transform) diff --git a/public/test-parcels/-100.104.material-component/game.ts b/public/test-parcels/-100.104.material-component/game.ts index c48da79cc..59ed500a4 100644 --- a/public/test-parcels/-100.104.material-component/game.ts +++ b/public/test-parcels/-100.104.material-component/game.ts @@ -1,24 +1,62 @@ -import { engine, Material, BoxShape, Entity, Transform, Color3 } from 'decentraland-ecs/src' +import { + engine, + Material, + BoxShape, + Entity, + Transform, + Color3, + OnPointerDown, + getComponentId, + log +} from 'decentraland-ecs/src' const box = new BoxShape() + const niceMaterial = new Material() niceMaterial.albedoColor = Color3.FromHexString('#FF0000') niceMaterial.metallic = 0.9 niceMaterial.roughness = 0.1 +log('niceMaterial', getComponentId(niceMaterial as any)) + +const niceNewMaterial = new Material() +niceNewMaterial.albedoColor = Color3.FromHexString('#00FFFF') +niceNewMaterial.metallic = 0.9 +niceNewMaterial.roughness = 1 +log('niceNewMaterial', getComponentId(niceNewMaterial as any)) -function spawn() { +function spawn(x: number, y: number, z: number) { const ent = new Entity() const transform = new Transform() - transform.position.x = Math.random() * 8 - transform.position.y = Math.random() * 8 - transform.position.z = Math.random() * 8 + transform.position.x = x + transform.position.y = y + transform.position.z = z ent.set(box) ent.set(niceMaterial) ent.set(transform) + + ent.set( + new OnPointerDown(() => { + log('setting ' + ent.uuid + ' <- ' + getComponentId(niceNewMaterial as any)) + ent.set(niceNewMaterial) + }) + ) + engine.addEntity(ent) + + return ent } +declare var dcl: any +const ent = spawn(5, 1, 5) + +dcl.onEvent((evt: any) => { + if (evt.type === 'TEST_TRIGGER') { + log('TEST_TRIGGER', evt) + ent.get(OnPointerDown).callback({} as any) + } +}) + for (let i = 0; i < 10; i++) { - spawn() + spawn(Math.random() * 8, Math.random() * 8 + 1, Math.random() * 8) } diff --git a/public/test-parcels/-100.109.input-api/game.ts b/public/test-parcels/-100.109.input-api/game.ts index 40c7d6981..88f9ce00a 100644 --- a/public/test-parcels/-100.109.input-api/game.ts +++ b/public/test-parcels/-100.109.input-api/game.ts @@ -9,8 +9,9 @@ import { Component, Vector3, Pointer, - OnClick, - Billboard + OnPointerDown, + Billboard, + log } from 'decentraland-ecs/src' declare var dcl: any @@ -61,9 +62,9 @@ const spawner = { z: (Math.random() - Math.random()) / 2 } - if (!ent.getOrNull(OnClick)) { + if (!ent.getOrNull(OnPointerDown)) { ent.set( - new OnClick(() => { + new OnPointerDown(() => { engine.removeEntity(ent) }) ) @@ -101,7 +102,7 @@ const spawner = { } class BubbleSystem implements ISystem { - group = engine.getComponentGroup(Transform, Velocity, OnClick) + group = engine.getComponentGroup(Transform, Velocity, OnPointerDown) isOutOfBounds(transform: Transform) { if ( @@ -137,11 +138,17 @@ class BubbleSystem implements ISystem { } input.subscribe('BUTTON_A_UP', e => { - console['log']('pointerUp works', e) + log('pointerUp works', e) }) input.subscribe('BUTTON_A_DOWN', e => { - console['log']('pointerDown works', e) + log('pointerDown works', e) }) engine.addSystem(new BubbleSystem()) + +dcl.onEvent(function(event: any) { + log('event', event) +}) + +log('init') diff --git a/public/test-parcels/-100.111.SkeletalAnimation/game.ts b/public/test-parcels/-100.111.SkeletalAnimation/game.ts index 5c5d3da21..ca58e413d 100644 --- a/public/test-parcels/-100.111.SkeletalAnimation/game.ts +++ b/public/test-parcels/-100.111.SkeletalAnimation/game.ts @@ -1,4 +1,14 @@ -import { Entity, GLTFShape, Transform, engine, Vector3, OnClick, AnimationClip, Animator } from 'decentraland-ecs' +import { + Entity, + GLTFShape, + Transform, + engine, + Vector3, + OnPointerDown, + AnimationClip, + Animator, + log +} from 'decentraland-ecs/src' // First way to const shark = new Entity() @@ -33,7 +43,7 @@ shark2.set( ) shark.set( - new OnClick(() => { + new OnPointerDown(() => { // just to test getting a clip const clip = animator.getClip('shark_skeleton_swim') if (clip) { @@ -44,3 +54,9 @@ shark.set( engine.addEntity(shark) engine.addEntity(shark2) + +declare var dcl: any + +dcl.onEvent(function(event: any) { + log('event', event) +}) diff --git a/public/test-parcels/-101.100-interaction-count/game.ts b/public/test-parcels/-101.100-interaction-count/game.ts new file mode 100644 index 000000000..df4eca96d --- /dev/null +++ b/public/test-parcels/-101.100-interaction-count/game.ts @@ -0,0 +1,85 @@ +import { engine, Entity, BoxShape, Transform, log, Material, Color3 } from 'decentraland-ecs' + +declare var dcl: any + +let counter = 0 +let entity: any = null +let shape: any = null +let material: any = null + +function executeAction() { + log(counter) + switch (counter) { + case 0: + log('CREATE_ENTITY') + entity = new Entity() + engine.addEntity(entity) + break + case 1: { + log('CREATE_SHAPE') + shape = new BoxShape() + entity.add(shape) + break + } + case 2: { + log('SET_TRANSFORM') + const t = entity.getOrCreate(Transform) + t.position.x = 5 + t.position.y = 5 + t.position.z = 5 + t.scale.x = 1.1 + t.scale.y = 1.1 + t.scale.z = 1.1 + break + } + case 3: { + log('SET_MATERIAL') + material = new Material() + entity.add(material) + break + } + case 4: { + log('SET_MATERIAL_COLOR') + material.albedoColor = Color3.FromHexString('#00FF00') + break + } + case 5: { + log('REMOVE_MATERIAL') + entity.remove(material) + // TODO: fix that `as any` + engine.disposeComponent(material as any) + material = null + break + } + case 6: { + log('REMOVE_SHAPE') + entity.remove(shape) + engine.disposeComponent(shape) + shape = null + break + } + case 7: { + log('REMOVE_TRANSFORM') + entity.remove(Transform) + break + } + case 8: { + log('REMOVE_ENTITY') + engine.removeEntity(entity) + break + } + } + + counter++ + + if (counter === 9) { + counter = 0 + } +} + +dcl.subscribe('pointerDown') +dcl.onEvent((evt: any) => { + if (evt.type === 'TEST_TRIGGER' || evt.type === 'pointerDown') { + executeAction() + } +}) diff --git a/public/test-parcels/-101.100-interaction-count/scene.json b/public/test-parcels/-101.100-interaction-count/scene.json new file mode 100644 index 000000000..f50146c4c --- /dev/null +++ b/public/test-parcels/-101.100-interaction-count/scene.json @@ -0,0 +1,30 @@ +{ + "display": { + "title": "interactive-text", + "favicon": "favicon_asset" + }, + "contact": { + "name": "king of the bongo", + "email": "" + }, + "owner": "", + "scene": { + "parcels": [ + "-101,100" + ], + "base": "-101,100" + }, + "communications": { + "type": "webrtc", + "signalling": "https://signalling-01.decentraland.org" + }, + "policy": { + "contentRating": "E", + "fly": true, + "voiceEnabled": true, + "blacklist": [], + "teleportPosition": "" + }, + "main": "game.js", + "tags": [] +} diff --git a/public/test-parcels/-101.100-interaction-count/tsconfig.json b/public/test-parcels/-101.100-interaction-count/tsconfig.json new file mode 100644 index 000000000..012d28c10 --- /dev/null +++ b/public/test-parcels/-101.100-interaction-count/tsconfig.json @@ -0,0 +1,7 @@ +{ + "compilerOptions": { + "baseUrl": "../../../packages", + "experimentalDecorators": true + }, + "includes": "*.ts" +} diff --git a/public/test-parcels/-102.102.gizmos/game.ts b/public/test-parcels/-102.102.gizmos/game.ts index e35c1faed..e8c32b64b 100644 --- a/public/test-parcels/-102.102.gizmos/game.ts +++ b/public/test-parcels/-102.102.gizmos/game.ts @@ -1,4 +1,4 @@ -import { Entity, engine, BoxShape, Gizmos, Transform, OnClick, log, OnGizmoEvent } from 'decentraland-ecs/src' +import { Entity, engine, BoxShape, Gizmos, Transform, OnPointerDown, log, OnGizmoEvent } from 'decentraland-ecs/src' const shape = new BoxShape() shape.visible = true @@ -37,7 +37,7 @@ function createCube(i: number) { } for (let i = 0; i < 16; i++) { - createCube(i).set(new OnClick(e => log(`click on ${i}`, e))) + createCube(i).set(new OnPointerDown(e => log(`click on ${i}`, e))) } log('initialized the cubes') diff --git a/public/test-parcels/-200.236-uuid-events/game.ts b/public/test-parcels/-200.236-uuid-events/game.ts index dd8f7faad..60a55fb52 100644 --- a/public/test-parcels/-200.236-uuid-events/game.ts +++ b/public/test-parcels/-200.236-uuid-events/game.ts @@ -1,4 +1,4 @@ -import { engine, Entity, BoxShape, Vector3, Transform, OnClick, log } from 'decentraland-ecs' +import { engine, Entity, BoxShape, Vector3, Transform, OnPointerDown, log } from 'decentraland-ecs' log('start') @@ -9,7 +9,7 @@ cube.getOrCreate(BoxShape) engine.addEntity(cube) -const onClickComponent = new OnClick(event => { +const onClickComponent = new OnPointerDown(event => { const t = cube.get(Transform) t.rotate(Vector3.Up(), 30) log(JSON.stringify(event)) diff --git a/scripts/test.ts b/scripts/test.ts index c3875cdb4..88074043c 100644 --- a/scripts/test.ts +++ b/scripts/test.ts @@ -164,6 +164,8 @@ function checkDiff(imageAPath: string, imageBPath: string, threshold: number, di res.end() }) .catch(e => { + console.log(` generating img: ${shouldGenerateNewImages} `) + console.log(` error: ${e} `) if (shouldGenerateNewImages) { // If the diff fails, it means images are different enough to be // commited as a test result to the repo. diff --git a/static/index.html b/static/index.html index b85ef4796..160072bce 100644 --- a/static/index.html +++ b/static/index.html @@ -2,7 +2,7 @@ - +