@adobe/data 0.7.0 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ecs/archetype/archetype.d.ts +3 -3
- package/dist/ecs/archetype/create-archetype.d.ts +4 -4
- package/dist/ecs/archetype/create-archetype.js.map +1 -1
- package/dist/ecs/archetype/create-archetype.test.js +6 -6
- package/dist/ecs/archetype/create-archetype.test.js.map +1 -1
- package/dist/ecs/archetype/delete-row.d.ts +2 -2
- package/dist/ecs/archetype/delete-row.js.map +1 -1
- package/dist/ecs/archetype/delete-row.test.js +4 -4
- package/dist/ecs/archetype/delete-row.test.js.map +1 -1
- package/dist/ecs/core-components.d.ts +3 -3
- package/dist/ecs/database/database.d.ts +4 -4
- package/dist/ecs/database/index.d.ts +1 -0
- package/dist/ecs/database/index.js +1 -0
- package/dist/ecs/database/index.js.map +1 -1
- package/dist/ecs/database/observe-select-entities.d.ts +2 -2
- package/dist/ecs/database/observe-select-entities.js.map +1 -1
- package/dist/ecs/database/observed/create-observed-database.js.map +1 -1
- package/dist/ecs/database/observed/observed-database.d.ts +3 -3
- package/dist/ecs/database/replicate.d.ts +9 -0
- package/dist/ecs/database/replicate.js +66 -0
- package/dist/ecs/database/replicate.js.map +1 -0
- package/dist/ecs/database/replicate.test.js +235 -0
- package/dist/ecs/database/replicate.test.js.map +1 -0
- package/dist/ecs/database/transactional-store/create-transactional-store.test.js +20 -0
- package/dist/ecs/database/transactional-store/create-transactional-store.test.js.map +1 -1
- package/dist/ecs/database/transactional-store/patch-entity-values.js +4 -1
- package/dist/ecs/database/transactional-store/patch-entity-values.js.map +1 -1
- package/dist/ecs/entity-location-table/create-entity-location-table.d.ts +1 -1
- package/dist/ecs/entity-location-table/create-entity-location-table.js +14 -1
- package/dist/ecs/entity-location-table/create-entity-location-table.js.map +1 -1
- package/dist/ecs/entity-location-table/create-entity-location-table.test.js +14 -0
- package/dist/ecs/entity-location-table/create-entity-location-table.test.js.map +1 -1
- package/dist/ecs/entity.d.ts +9 -7
- package/dist/ecs/entity.js +5 -2
- package/dist/ecs/entity.js.map +1 -1
- package/dist/ecs/index.d.ts +1 -1
- package/dist/ecs/index.js +1 -1
- package/dist/ecs/index.js.map +1 -1
- package/dist/ecs/optional-components.d.ts +3 -0
- package/dist/ecs/optional-components.js +2 -0
- package/dist/ecs/optional-components.js.map +1 -0
- package/dist/ecs/required-components.d.ts +4 -0
- package/dist/ecs/required-components.js +2 -0
- package/dist/ecs/required-components.js.map +1 -0
- package/dist/ecs/store/core/core.d.ts +15 -15
- package/dist/ecs/store/core/create-core.d.ts +2 -1
- package/dist/ecs/store/core/create-core.js +34 -14
- package/dist/ecs/store/core/create-core.js.map +1 -1
- package/dist/ecs/store/core/create-core.test.d.ts +1 -1
- package/dist/ecs/store/core/create-core.test.js +30 -2
- package/dist/ecs/store/core/create-core.test.js.map +1 -1
- package/dist/ecs/store/core/select-entities.d.ts +2 -2
- package/dist/ecs/store/core/select-entities.js.map +1 -1
- package/dist/ecs/store/create-store.d.ts +2 -1
- package/dist/ecs/store/create-store.js +3 -1
- package/dist/ecs/store/create-store.js.map +1 -1
- package/dist/ecs/store/store.d.ts +6 -6
- package/dist/samples/todo/services/state-service/create-todo-database.d.ts +2 -2
- package/dist/samples/todo/services/state-service/create-todo-store.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/dist/blob/download-handle.d.ts +0 -4
- package/dist/blob/download-handle.js +0 -2
- package/dist/blob/download-handle.js.map +0 -1
- package/dist/blob/upload-handle.d.ts +0 -4
- package/dist/blob/upload-handle.js +0 -2
- package/dist/blob/upload-handle.js.map +0 -1
- package/dist/ecs/database/transactional-store/entity-id-preservation.test.js +0 -106
- package/dist/ecs/database/transactional-store/entity-id-preservation.test.js.map +0 -1
- package/dist/ecs/entity/entity.d.ts +0 -8
- package/dist/ecs/entity/entity.js +0 -3
- package/dist/ecs/entity/entity.js.map +0 -1
- package/dist/ecs/entity/u32.d.ts +0 -8
- package/dist/ecs/entity/u32.js +0 -24
- package/dist/ecs/entity/u32.js.map +0 -1
- package/dist/ecs/store/store-schema/create-store-schema-test.d.ts +0 -1
- package/dist/ecs/store/store-schema/create-store-schema-test.js +0 -33
- package/dist/ecs/store/store-schema/create-store-schema-test.js.map +0 -1
- package/dist/ecs/store/store-schema/create-store-schema.d.ts +0 -1
- package/dist/ecs/store/store-schema/create-store-schema.js +0 -45
- package/dist/ecs/store/store-schema/create-store-schema.js.map +0 -1
- package/dist/ecs/store/store-schema/index.d.ts +0 -1
- package/dist/ecs/store/store-schema/index.js +0 -21
- package/dist/ecs/store/store-schema/index.js.map +0 -1
- package/dist/ecs/store/store-schema/store-schema.d.ts +0 -1
- package/dist/ecs/store/store-schema/store-schema.js +0 -57
- package/dist/ecs/store/store-schema/store-schema.js.map +0 -1
- package/dist/ecs/world/create-world.d.ts +0 -7
- package/dist/ecs/world/create-world.js +0 -113
- package/dist/ecs/world/create-world.js.map +0 -1
- package/dist/ecs/world/create-world.test.d.ts +0 -1
- package/dist/ecs/world/create-world.test.js +0 -499
- package/dist/ecs/world/create-world.test.js.map +0 -1
- package/dist/ecs/world/index.d.ts +0 -5
- package/dist/ecs/world/index.js +0 -27
- package/dist/ecs/world/index.js.map +0 -1
- package/dist/ecs/world/system-phase.d.ts +0 -5
- package/dist/ecs/world/system-phase.js +0 -14
- package/dist/ecs/world/system-phase.js.map +0 -1
- package/dist/ecs/world/system.d.ts +0 -25
- package/dist/ecs/world/system.js +0 -2
- package/dist/ecs/world/system.js.map +0 -1
- package/dist/ecs/world/world-schema/create-world-schema-test.d.ts +0 -1
- package/dist/ecs/world/world-schema/create-world-schema-test.js +0 -55
- package/dist/ecs/world/world-schema/create-world-schema-test.js.map +0 -1
- package/dist/ecs/world/world-schema/create-world-schema.d.ts +0 -19
- package/dist/ecs/world/world-schema/create-world-schema.js +0 -33
- package/dist/ecs/world/world-schema/create-world-schema.js.map +0 -1
- package/dist/ecs/world/world-schema/index.d.ts +0 -2
- package/dist/ecs/world/world-schema/index.js +0 -24
- package/dist/ecs/world/world-schema/index.js.map +0 -1
- package/dist/ecs/world/world-schema/world-schema.d.ts +0 -18
- package/dist/ecs/world/world-schema/world-schema.js +0 -23
- package/dist/ecs/world/world-schema/world-schema.js.map +0 -1
- package/dist/ecs/world/world.d.ts +0 -11
- package/dist/ecs/world/world.js +0 -2
- package/dist/ecs/world/world.js.map +0 -1
- package/dist/graphics/camera/camera.d.ts +0 -62
- package/dist/graphics/camera/camera.js +0 -17
- package/dist/graphics/camera/camera.js.map +0 -1
- package/dist/graphics/camera/index.d.ts +0 -4
- package/dist/graphics/camera/index.js +0 -5
- package/dist/graphics/camera/index.js.map +0 -1
- package/dist/graphics/camera/screen-to-world-ray.d.ts +0 -12
- package/dist/graphics/camera/screen-to-world-ray.js +0 -49
- package/dist/graphics/camera/screen-to-world-ray.js.map +0 -1
- package/dist/graphics/camera/screen-to-world-ray.test.d.ts +0 -1
- package/dist/graphics/camera/screen-to-world-ray.test.js +0 -171
- package/dist/graphics/camera/screen-to-world-ray.test.js.map +0 -1
- package/dist/graphics/camera/to-view-projection.d.ts +0 -3
- package/dist/graphics/camera/to-view-projection.js +0 -8
- package/dist/graphics/camera/to-view-projection.js.map +0 -1
- package/dist/graphics/camera/world-to-screen.d.ts +0 -12
- package/dist/graphics/camera/world-to-screen.js +0 -38
- package/dist/graphics/camera/world-to-screen.js.map +0 -1
- package/dist/graphics/camera/world-to-screen.test.d.ts +0 -1
- package/dist/graphics/camera/world-to-screen.test.js +0 -124
- package/dist/graphics/camera/world-to-screen.test.js.map +0 -1
- package/dist/graphics/create-struct-gpu-buffer.d.ts +0 -7
- package/dist/graphics/create-struct-gpu-buffer.js +0 -17
- package/dist/graphics/create-struct-gpu-buffer.js.map +0 -1
- package/dist/graphics/extract-wgsl-bindings.d.ts +0 -5
- package/dist/graphics/extract-wgsl-bindings.js +0 -10
- package/dist/graphics/extract-wgsl-bindings.js.map +0 -1
- package/dist/graphics/frame.d.ts +0 -1
- package/dist/graphics/frame.js +0 -15
- package/dist/graphics/frame.js.map +0 -1
- package/dist/graphics/get-web-gpu-device-and-context.d.ts +0 -1
- package/dist/graphics/get-web-gpu-device-and-context.js +0 -24
- package/dist/graphics/get-web-gpu-device-and-context.js.map +0 -1
- package/dist/graphics/graphics-context.d.ts +0 -1
- package/dist/graphics/graphics-context.js +0 -7
- package/dist/graphics/graphics-context.js.map +0 -1
- package/dist/graphics/index.d.ts +0 -5
- package/dist/graphics/index.js +0 -5
- package/dist/graphics/index.js.map +0 -1
- package/dist/graphics/to-gpu-buffer.d.ts +0 -2
- package/dist/graphics/to-gpu-buffer.js +0 -14
- package/dist/graphics/to-gpu-buffer.js.map +0 -1
- package/dist/internal/array-buffer-like/grow.d.ts +0 -1
- package/dist/internal/array-buffer-like/grow.js +0 -9
- package/dist/internal/array-buffer-like/grow.js.map +0 -1
- package/dist/math/aabb-face/face.d.ts +0 -51
- package/dist/math/aabb-face/face.js +0 -110
- package/dist/math/aabb-face/face.js.map +0 -1
- package/dist/math/aabb-face/face.test.d.ts +0 -1
- package/dist/math/aabb-face/face.test.js +0 -94
- package/dist/math/aabb-face/face.test.js.map +0 -1
- package/dist/math/box/box.d.ts +0 -50
- package/dist/math/box/box.js +0 -23
- package/dist/math/box/box.js.map +0 -1
- package/dist/math/face/face.d.ts +0 -51
- package/dist/math/face/face.js +0 -110
- package/dist/math/face/face.js.map +0 -1
- package/dist/math/face/face.test.d.ts +0 -1
- package/dist/math/face/face.test.js +0 -94
- package/dist/math/face/face.test.js.map +0 -1
- package/dist/math/picking/face.d.ts +0 -1
- package/dist/math/picking/face.js +0 -2
- package/dist/math/picking/face.js.map +0 -1
- package/dist/math/picking/get-closest-entity-to-line.d.ts +0 -4
- package/dist/math/picking/get-closest-entity-to-line.js +0 -30
- package/dist/math/picking/get-closest-entity-to-line.js.map +0 -1
- package/dist/math/picking/get-closest-entity-to-point.d.ts +0 -4
- package/dist/math/picking/get-closest-entity-to-point.js +0 -27
- package/dist/math/picking/get-closest-entity-to-point.js.map +0 -1
- package/dist/math/picking/get-intersecting-entities.d.ts +0 -12
- package/dist/math/picking/get-intersecting-entities.js +0 -15
- package/dist/math/picking/get-intersecting-entities.js.map +0 -1
- package/dist/math/picking/getClosestEntityToLine.d.ts +0 -4
- package/dist/math/picking/getClosestEntityToLine.js +0 -29
- package/dist/math/picking/getClosestEntityToLine.js.map +0 -1
- package/dist/math/picking/getClosestEntityToPoint.d.ts +0 -4
- package/dist/math/picking/getClosestEntityToPoint.js +0 -27
- package/dist/math/picking/getClosestEntityToPoint.js.map +0 -1
- package/dist/math/picking/getIntersectingEntities.d.ts +0 -12
- package/dist/math/picking/getIntersectingEntities.js +0 -15
- package/dist/math/picking/getIntersectingEntities.js.map +0 -1
- package/dist/math/picking/index.d.ts +0 -5
- package/dist/math/picking/index.js +0 -27
- package/dist/math/picking/index.js.map +0 -1
- package/dist/math/picking/pick-from-tables.d.ts +0 -19
- package/dist/math/picking/pick-from-tables.js +0 -63
- package/dist/math/picking/pick-from-tables.js.map +0 -1
- package/dist/math/picking/pick-result.d.ts +0 -12
- package/dist/math/picking/pick-result.js +0 -23
- package/dist/math/picking/pick-result.js.map +0 -1
- package/dist/math/transform/debug-inverse.d.ts +0 -1
- package/dist/math/transform/debug-inverse.js +0 -28
- package/dist/math/transform/debug-inverse.js.map +0 -1
- package/dist/math/transform/debug-quat.d.ts +0 -1
- package/dist/math/transform/debug-quat.js +0 -23
- package/dist/math/transform/debug-quat.js.map +0 -1
- package/dist/math/transform/debug-test.d.ts +0 -1
- package/dist/math/transform/debug-test.js +0 -34
- package/dist/math/transform/debug-test.js.map +0 -1
- package/dist/math/transform/transform.d.ts +0 -58
- package/dist/math/transform/transform.js +0 -101
- package/dist/math/transform/transform.js.map +0 -1
- package/dist/math/transform/transform.test.d.ts +0 -1
- package/dist/math/transform/transform.test.js +0 -309
- package/dist/math/transform/transform.test.js.map +0 -1
- package/dist/old-ecs/privacy/helper-functions.d.ts +0 -43
- package/dist/old-ecs/privacy/helper-functions.js +0 -76
- package/dist/old-ecs/privacy/helper-functions.js.map +0 -1
- package/dist/old-ecs/privacy/helper-functions.test.d.ts +0 -1
- package/dist/old-ecs/privacy/helper-functions.test.js +0 -173
- package/dist/old-ecs/privacy/helper-functions.test.js.map +0 -1
- /package/dist/ecs/database/{transactional-store/entity-id-preservation.test.d.ts → replicate.test.d.ts} +0 -0
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*MIT License
|
|
2
|
-
|
|
3
|
-
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.*/
|
|
22
|
-
import { createWorldSchema } from "./create-world-schema.js";
|
|
23
|
-
const worldSchema = createWorldSchema({
|
|
24
|
-
velocity: { type: "number" },
|
|
25
|
-
particle: { type: "boolean" },
|
|
26
|
-
}, {
|
|
27
|
-
mousePosition: { type: "number", default: 0 },
|
|
28
|
-
fooPosition: { type: "number", default: 0 },
|
|
29
|
-
}, {
|
|
30
|
-
Particle: ["particle"],
|
|
31
|
-
DynamicParticle: ["particle", "velocity"],
|
|
32
|
-
}, {
|
|
33
|
-
createParticle(t, args) {
|
|
34
|
-
},
|
|
35
|
-
createDynamicParticle(t, args) {
|
|
36
|
-
}
|
|
37
|
-
}, {
|
|
38
|
-
foo: {
|
|
39
|
-
type: "store",
|
|
40
|
-
run: (store) => {
|
|
41
|
-
// @ts-expect-error
|
|
42
|
-
store.archetypes.NonParticle;
|
|
43
|
-
store.archetypes.Particle.insert({ particle: true });
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
bar: {
|
|
47
|
-
type: "database",
|
|
48
|
-
run: (db) => {
|
|
49
|
-
// @ts-expect-error
|
|
50
|
-
db.transactions.nonTransaction;
|
|
51
|
-
db.transactions.createParticle({ particle: true });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=create-world-schema-test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-world-schema-test.js","sourceRoot":"","sources":["../../../../src/ecs/world/world-schema/create-world-schema-test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAQX,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,WAAW,GAAG,iBAAiB,CACjC;IACI,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC5B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;CAChC,EACD;IACI,aAAa,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE;IAC7C,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAAE;CAC9C,EACD;IACI,QAAQ,EAAE,CAAC,UAAU,CAAC;IACtB,eAAe,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;CAC5C,EACD;IACI,cAAc,CAAC,CAAC,EAAE,IAA2B;IAC7C,CAAC;IACD,qBAAqB,CAAC,CAAC,EAAE,IAA6C;IACtE,CAAC;CACJ,EACD;IACI,GAAG,EAAE;QACD,IAAI,EAAE,OAAO;QACb,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;YACX,mBAAmB;YACnB,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC;YAC7B,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,CAAC;KACJ;IACD,GAAG,EAAE;QACD,IAAI,EAAE,UAAU;QAChB,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE;YACR,mBAAmB;YACnB,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC;YAC/B,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,CAAC;KACJ;CACJ,CACJ,CAAA"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { FromSchemas } from "../../../schema/schema.js";
|
|
2
|
-
import { StringKeyof } from "../../../types/types.js";
|
|
3
|
-
import { ComponentSchemas } from "../../component-schemas.js";
|
|
4
|
-
import { System, ToTransactionFunctions, TransactionDeclarations } from "../../index.js";
|
|
5
|
-
import { ResourceSchemas } from "../../resource-schemas.js";
|
|
6
|
-
import { ArchetypeComponents } from "../../store/archetype-components.js";
|
|
7
|
-
import { WorldFromSchema, WorldSchema } from "./world-schema.js";
|
|
8
|
-
export declare function createWorldSchema<const CS extends ComponentSchemas, const RS extends ResourceSchemas, const A extends ArchetypeComponents<StringKeyof<CS>>, const TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A>, const SD extends {
|
|
9
|
-
readonly [K: string]: System<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, StringKeyof<SD>>;
|
|
10
|
-
}>(components: CS, resources: RS, archetypes: A, transactions: TD, systems: SD): {
|
|
11
|
-
readonly components: CS;
|
|
12
|
-
readonly resources: RS;
|
|
13
|
-
readonly archetypes: A;
|
|
14
|
-
readonly transactions: TD;
|
|
15
|
-
readonly systems: SD;
|
|
16
|
-
};
|
|
17
|
-
export declare function createWorldFromSchema<const CS extends ComponentSchemas, const RS extends ResourceSchemas, const A extends ArchetypeComponents<StringKeyof<CS>>, const TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A>, const SD extends {
|
|
18
|
-
readonly [K: string]: System<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, StringKeyof<SD>>;
|
|
19
|
-
}>(schema: WorldSchema<CS, RS, A, TD, SD>): WorldFromSchema<typeof schema>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*MIT License
|
|
2
|
-
|
|
3
|
-
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.*/
|
|
22
|
-
import { createDatabase, createStoreFromSchema, createWorld } from "../../index.js";
|
|
23
|
-
export function createWorldSchema(components, resources, archetypes, transactions, systems) {
|
|
24
|
-
return { components, resources, archetypes, transactions, systems };
|
|
25
|
-
}
|
|
26
|
-
;
|
|
27
|
-
export function createWorldFromSchema(schema) {
|
|
28
|
-
const store = createStoreFromSchema(schema);
|
|
29
|
-
const database = createDatabase(store, schema.transactions);
|
|
30
|
-
return createWorld(store, database, schema.systems);
|
|
31
|
-
}
|
|
32
|
-
;
|
|
33
|
-
//# sourceMappingURL=create-world-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-world-schema.js","sourceRoot":"","sources":["../../../../src/ecs/world/world-schema/create-world-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAKX,OAAO,EAA2D,cAAc,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAK7I,MAAM,UAAU,iBAAiB,CAO7B,UAAc,EACd,SAAa,EACb,UAAa,EACb,YAAgB,EAChB,OAAW;IAEX,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAoD,CAAC;AAC1H,CAAC;AAAA,CAAC;AAEF,MAAM,UAAU,qBAAqB,CAOjC,MAAsC;IAEtC,MAAM,KAAK,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,YAAmB,CAAC,CAAC;IACnE,OAAO,WAAW,CACd,KAAK,EACL,QAAe,EACf,MAAM,CAAC,OAAc,CACjB,CAAC;AACb,CAAC;AAAA,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*MIT License
|
|
2
|
-
|
|
3
|
-
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.*/
|
|
22
|
-
export * from "./create-world-schema.js";
|
|
23
|
-
export * from "./world-schema.js";
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ecs/world/world-schema/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { FromSchemas } from "../../../schema/schema.js";
|
|
2
|
-
import { ComponentSchemas } from "../../component-schemas.js";
|
|
3
|
-
import { ResourceSchemas } from "../../resource-schemas.js";
|
|
4
|
-
import { StringKeyof } from "../../../types/types.js";
|
|
5
|
-
import { ToTransactionFunctions, TransactionDeclarations } from "../../database/database.js";
|
|
6
|
-
import { ArchetypeComponents } from "../../store/archetype-components.js";
|
|
7
|
-
import { World } from "../world.js";
|
|
8
|
-
import { System } from "../system.js";
|
|
9
|
-
export type WorldSchema<CS extends ComponentSchemas, RS extends ResourceSchemas, A extends ArchetypeComponents<StringKeyof<CS>>, TD extends TransactionDeclarations<FromSchemas<CS>, FromSchemas<RS>, A>, SD extends {
|
|
10
|
-
readonly [K: string]: System<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, StringKeyof<SD>>;
|
|
11
|
-
}> = {
|
|
12
|
-
readonly components: CS;
|
|
13
|
-
readonly resources: RS;
|
|
14
|
-
readonly archetypes: A;
|
|
15
|
-
readonly transactions: TD;
|
|
16
|
-
readonly systems: SD;
|
|
17
|
-
};
|
|
18
|
-
export type WorldFromSchema<T> = T extends WorldSchema<infer CS, infer RS, infer A, infer TD, infer SD> ? World<FromSchemas<CS>, FromSchemas<RS>, A, ToTransactionFunctions<TD>, StringKeyof<SD>> : never;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*MIT License
|
|
2
|
-
|
|
3
|
-
© Copyright 2025 Adobe. All rights reserved.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.*/
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=world-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"world-schema.js","sourceRoot":"","sources":["../../../../src/ecs/world/world-schema/world-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ResourceComponents } from "../store/resource-components.js";
|
|
2
|
-
import { StringKeyof } from "../../types/types.js";
|
|
3
|
-
import { Components } from "../store/components.js";
|
|
4
|
-
import { ArchetypeComponents } from "../store/archetype-components.js";
|
|
5
|
-
import { Database, TransactionFunctions } from "../database/database.js";
|
|
6
|
-
import { SystemPhase } from "./system-phase.js";
|
|
7
|
-
export type SystemNames = string;
|
|
8
|
-
export interface World<C extends Components = never, R extends ResourceComponents = never, A extends ArchetypeComponents<StringKeyof<C>> = never, T extends TransactionFunctions = never, S extends SystemNames = never> extends Database<C, R, A, T> {
|
|
9
|
-
runPhases(phases?: readonly SystemPhase[]): Promise<void>;
|
|
10
|
-
runSystems(systems: readonly S[]): Promise<void>;
|
|
11
|
-
}
|
package/dist/ecs/world/world.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"world.js","sourceRoot":"","sources":["../../../src/ecs/world/world.ts"],"names":[],"mappings":""}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { FromSchema } from "../../schema/index.js";
|
|
2
|
-
export declare const CameraSchema: {
|
|
3
|
-
readonly type: "object";
|
|
4
|
-
readonly properties: {
|
|
5
|
-
readonly aspect: {
|
|
6
|
-
readonly type: "number";
|
|
7
|
-
readonly precision: 1;
|
|
8
|
-
readonly default: number;
|
|
9
|
-
};
|
|
10
|
-
readonly fieldOfView: {
|
|
11
|
-
readonly type: "number";
|
|
12
|
-
readonly precision: 1;
|
|
13
|
-
readonly default: number;
|
|
14
|
-
};
|
|
15
|
-
readonly nearPlane: {
|
|
16
|
-
readonly type: "number";
|
|
17
|
-
readonly precision: 1;
|
|
18
|
-
readonly default: number;
|
|
19
|
-
};
|
|
20
|
-
readonly farPlane: {
|
|
21
|
-
readonly type: "number";
|
|
22
|
-
readonly precision: 1;
|
|
23
|
-
readonly default: number;
|
|
24
|
-
};
|
|
25
|
-
readonly position: {
|
|
26
|
-
readonly type: "array";
|
|
27
|
-
readonly items: {
|
|
28
|
-
readonly type: "number";
|
|
29
|
-
readonly precision: 1;
|
|
30
|
-
readonly default: number;
|
|
31
|
-
};
|
|
32
|
-
readonly minItems: 3;
|
|
33
|
-
readonly maxItems: 3;
|
|
34
|
-
readonly default: readonly [0, 0, 0];
|
|
35
|
-
};
|
|
36
|
-
readonly target: {
|
|
37
|
-
readonly type: "array";
|
|
38
|
-
readonly items: {
|
|
39
|
-
readonly type: "number";
|
|
40
|
-
readonly precision: 1;
|
|
41
|
-
readonly default: number;
|
|
42
|
-
};
|
|
43
|
-
readonly minItems: 3;
|
|
44
|
-
readonly maxItems: 3;
|
|
45
|
-
readonly default: readonly [0, 0, 0];
|
|
46
|
-
};
|
|
47
|
-
readonly up: {
|
|
48
|
-
readonly type: "array";
|
|
49
|
-
readonly items: {
|
|
50
|
-
readonly type: "number";
|
|
51
|
-
readonly precision: 1;
|
|
52
|
-
readonly default: number;
|
|
53
|
-
};
|
|
54
|
-
readonly minItems: 3;
|
|
55
|
-
readonly maxItems: 3;
|
|
56
|
-
readonly default: readonly [0, 0, 0];
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
readonly required: readonly ["aspect", "fieldOfView", "nearPlane", "farPlane", "position", "target", "up"];
|
|
60
|
-
readonly additionalProperties: false;
|
|
61
|
-
};
|
|
62
|
-
export type Camera = FromSchema<typeof CameraSchema>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { F32Schema } from "../../schema/index.js";
|
|
2
|
-
import { Vec3 } from "../../math/index.js";
|
|
3
|
-
export const CameraSchema = {
|
|
4
|
-
type: 'object',
|
|
5
|
-
properties: {
|
|
6
|
-
aspect: F32Schema,
|
|
7
|
-
fieldOfView: F32Schema,
|
|
8
|
-
nearPlane: F32Schema,
|
|
9
|
-
farPlane: F32Schema,
|
|
10
|
-
position: Vec3.schema,
|
|
11
|
-
target: Vec3.schema,
|
|
12
|
-
up: Vec3.schema,
|
|
13
|
-
},
|
|
14
|
-
required: ["aspect", "fieldOfView", "nearPlane", "farPlane", "position", "target", "up"],
|
|
15
|
-
additionalProperties: false,
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=camera.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../../src/graphics/camera/camera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsB,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACR,MAAM,EAAE,SAAS;QACjB,WAAW,EAAE,SAAS;QACtB,SAAS,EAAE,SAAS;QACpB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,IAAI,CAAC,MAAM;QACrB,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,EAAE,EAAE,IAAI,CAAC,MAAM;KAClB;IACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,CAAC;IACxF,oBAAoB,EAAE,KAAK;CACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/graphics/camera/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Vec2, Line3, Mat4x4 } from "../../math/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Converts screen coordinates to a world space pick line for ray casting.
|
|
4
|
-
*
|
|
5
|
-
* @param screenPosition - Screen coordinates [x, y] where (0,0) is top-left
|
|
6
|
-
* @param invViewProjection - The inverse view-projection matrix
|
|
7
|
-
* @param canvasWidth - The width of the canvas in pixels
|
|
8
|
-
* @param canvasHeight - The height of the canvas in pixels
|
|
9
|
-
* @param rayLength - The length of the ray in world units (default: 1000)
|
|
10
|
-
* @returns A Line3 representing the ray from near plane through the screen point
|
|
11
|
-
*/
|
|
12
|
-
export declare const screenToWorldRay: (screenPosition: Vec2, invViewProjection: Mat4x4, canvasWidth: number, canvasHeight: number, rayLength?: number) => Line3;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Vec3, Mat4x4 } from "../../math/index.js";
|
|
2
|
-
/**
|
|
3
|
-
* Converts screen coordinates to a world space pick line for ray casting.
|
|
4
|
-
*
|
|
5
|
-
* @param screenPosition - Screen coordinates [x, y] where (0,0) is top-left
|
|
6
|
-
* @param invViewProjection - The inverse view-projection matrix
|
|
7
|
-
* @param canvasWidth - The width of the canvas in pixels
|
|
8
|
-
* @param canvasHeight - The height of the canvas in pixels
|
|
9
|
-
* @param rayLength - The length of the ray in world units (default: 1000)
|
|
10
|
-
* @returns A Line3 representing the ray from near plane through the screen point
|
|
11
|
-
*/
|
|
12
|
-
export const screenToWorldRay = (screenPosition, invViewProjection, canvasWidth, canvasHeight, rayLength = 1000) => {
|
|
13
|
-
// Convert screen coordinates to normalized device coordinates (NDC)
|
|
14
|
-
// Screen: (0,0) is top-left, (width,height) is bottom-right
|
|
15
|
-
// NDC: (-1,-1) is bottom-left, (1,1) is top-right
|
|
16
|
-
const ndcX = (screenPosition[0] / canvasWidth) * 2 - 1;
|
|
17
|
-
const ndcY = 1 - (screenPosition[1] / canvasHeight) * 2; // Flip Y axis
|
|
18
|
-
// Create two points in clip space: near plane and far plane
|
|
19
|
-
// Near plane is at z = -1 (closer to camera), far plane is at z = 1 (farther from camera)
|
|
20
|
-
const nearPoint = [ndcX, ndcY, -1, 1];
|
|
21
|
-
const farPoint = [ndcX, ndcY, 1, 1];
|
|
22
|
-
// Transform to world space
|
|
23
|
-
const nearWorld = Mat4x4.multiplyVec4(invViewProjection, nearPoint);
|
|
24
|
-
const farWorld = Mat4x4.multiplyVec4(invViewProjection, farPoint);
|
|
25
|
-
// Perform perspective divide and ensure Vec3 type
|
|
26
|
-
const nearWorldPos = [
|
|
27
|
-
nearWorld[0] / nearWorld[3],
|
|
28
|
-
nearWorld[1] / nearWorld[3],
|
|
29
|
-
nearWorld[2] / nearWorld[3]
|
|
30
|
-
];
|
|
31
|
-
const farWorldPos = [
|
|
32
|
-
farWorld[0] / farWorld[3],
|
|
33
|
-
farWorld[1] / farWorld[3],
|
|
34
|
-
farWorld[2] / farWorld[3]
|
|
35
|
-
];
|
|
36
|
-
// Calculate ray direction (from near to far, which should point towards negative Z)
|
|
37
|
-
const rayDirection = Vec3.normalize(Vec3.subtract(nearWorldPos, farWorldPos));
|
|
38
|
-
// Create the ray end point at the specified length from the near plane point
|
|
39
|
-
const rayEnd = [
|
|
40
|
-
nearWorldPos[0] + rayDirection[0] * rayLength,
|
|
41
|
-
nearWorldPos[1] + rayDirection[1] * rayLength,
|
|
42
|
-
nearWorldPos[2] + rayDirection[2] * rayLength
|
|
43
|
-
];
|
|
44
|
-
return {
|
|
45
|
-
a: nearWorldPos,
|
|
46
|
-
b: rayEnd
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=screen-to-world-ray.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screen-to-world-ray.js","sourceRoot":"","sources":["../../../src/graphics/camera/screen-to-world-ray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAS,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC5B,cAAoB,EACpB,iBAAyB,EACzB,WAAmB,EACnB,YAAoB,EACpB,YAAoB,IAAI,EACnB,EAAE;IACP,oEAAoE;IACpE,4DAA4D;IAC5D,kDAAkD;IAClD,MAAM,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc;IAEvE,4DAA4D;IAC5D,0FAA0F;IAC1F,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAU,CAAC;IAC/C,MAAM,QAAQ,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAU,CAAC;IAE7C,2BAA2B;IAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY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} from "./to-view-projection.js";
|
|
4
|
-
import { Mat4x4 } from "../../math/index.js";
|
|
5
|
-
describe("screenToWorldRay", () => {
|
|
6
|
-
const createTestCamera = () => ({
|
|
7
|
-
aspect: 16 / 9,
|
|
8
|
-
fieldOfView: Math.PI / 4, // 45 degrees
|
|
9
|
-
nearPlane: 0.1,
|
|
10
|
-
farPlane: 100,
|
|
11
|
-
position: [0, 0, 5],
|
|
12
|
-
target: [0, 0, 0],
|
|
13
|
-
up: [0, 1, 0],
|
|
14
|
-
});
|
|
15
|
-
it("converts screen center to ray pointing forward", () => {
|
|
16
|
-
const camera = createTestCamera();
|
|
17
|
-
const canvasWidth = 1600;
|
|
18
|
-
const canvasHeight = 900;
|
|
19
|
-
const screenCenter = [canvasWidth / 2, canvasHeight / 2];
|
|
20
|
-
// Compute the inverse view-projection matrix
|
|
21
|
-
const viewProjection = toViewProjection(camera);
|
|
22
|
-
const invViewProjection = Mat4x4.inverse(viewProjection);
|
|
23
|
-
const ray = screenToWorldRay(screenCenter, invViewProjection, canvasWidth, canvasHeight);
|
|
24
|
-
// Ray should start at near plane point (not camera position)
|
|
25
|
-
expect(ray.a[0]).toBeCloseTo(0, 1);
|
|
26
|
-
expect(ray.a[1]).toBeCloseTo(0, 1);
|
|
27
|
-
expect(ray.a[2]).toBeCloseTo(5, 1); // Near plane is actually at z = 5
|
|
28
|
-
// Ray should point roughly toward the target (forward direction)
|
|
29
|
-
const rayDirection = [
|
|
30
|
-
ray.b[0] - ray.a[0],
|
|
31
|
-
ray.b[1] - ray.a[1],
|
|
32
|
-
ray.b[2] - ray.a[2]
|
|
33
|
-
];
|
|
34
|
-
// Normalize the direction
|
|
35
|
-
const length = Math.sqrt(rayDirection[0] ** 2 + rayDirection[1] ** 2 + rayDirection[2] ** 2);
|
|
36
|
-
const normalizedDirection = [
|
|
37
|
-
rayDirection[0] / length,
|
|
38
|
-
rayDirection[1] / length,
|
|
39
|
-
rayDirection[2] / length
|
|
40
|
-
];
|
|
41
|
-
// Should point roughly forward (negative Z direction, into the scene)
|
|
42
|
-
expect(normalizedDirection[0]).toBeCloseTo(0, 1);
|
|
43
|
-
expect(normalizedDirection[1]).toBeCloseTo(0, 1);
|
|
44
|
-
expect(normalizedDirection[2]).toBeCloseTo(-1, 1);
|
|
45
|
-
});
|
|
46
|
-
it("converts screen top-left to ray pointing left and up", () => {
|
|
47
|
-
const camera = createTestCamera();
|
|
48
|
-
const canvasWidth = 1600;
|
|
49
|
-
const canvasHeight = 900;
|
|
50
|
-
const screenTopLeft = [0, 0];
|
|
51
|
-
// Compute the inverse view-projection matrix
|
|
52
|
-
const viewProjection = toViewProjection(camera);
|
|
53
|
-
const invViewProjection = Mat4x4.inverse(viewProjection);
|
|
54
|
-
const ray = screenToWorldRay(screenTopLeft, invViewProjection, canvasWidth, canvasHeight);
|
|
55
|
-
// Ray should start at near plane point
|
|
56
|
-
expect(ray.a[2]).toBeCloseTo(5, 1); // Near plane
|
|
57
|
-
// Ray should point left and up
|
|
58
|
-
const rayDirection = [
|
|
59
|
-
ray.b[0] - ray.a[0],
|
|
60
|
-
ray.b[1] - ray.a[1],
|
|
61
|
-
ray.b[2] - ray.a[2]
|
|
62
|
-
];
|
|
63
|
-
// Normalize the direction
|
|
64
|
-
const length = Math.sqrt(rayDirection[0] ** 2 + rayDirection[1] ** 2 + rayDirection[2] ** 2);
|
|
65
|
-
const normalizedDirection = [
|
|
66
|
-
rayDirection[0] / length,
|
|
67
|
-
rayDirection[1] / length,
|
|
68
|
-
rayDirection[2] / length
|
|
69
|
-
];
|
|
70
|
-
// Should point left (negative X), up (positive Y), and forward (negative Z, into scene)
|
|
71
|
-
expect(normalizedDirection[0]).toBeLessThan(0);
|
|
72
|
-
expect(normalizedDirection[1]).toBeGreaterThan(0);
|
|
73
|
-
expect(normalizedDirection[2]).toBeLessThan(0);
|
|
74
|
-
});
|
|
75
|
-
it("converts screen bottom-right to ray pointing right and down", () => {
|
|
76
|
-
const camera = createTestCamera();
|
|
77
|
-
const canvasWidth = 1600;
|
|
78
|
-
const canvasHeight = 900;
|
|
79
|
-
const screenBottomRight = [canvasWidth, canvasHeight];
|
|
80
|
-
// Compute the inverse view-projection matrix
|
|
81
|
-
const viewProjection = toViewProjection(camera);
|
|
82
|
-
const invViewProjection = Mat4x4.inverse(viewProjection);
|
|
83
|
-
const ray = screenToWorldRay(screenBottomRight, invViewProjection, canvasWidth, canvasHeight);
|
|
84
|
-
// Ray should start at near plane point
|
|
85
|
-
expect(ray.a[2]).toBeCloseTo(5, 1); // Near plane
|
|
86
|
-
// Ray should point right and down
|
|
87
|
-
const rayDirection = [
|
|
88
|
-
ray.b[0] - ray.a[0],
|
|
89
|
-
ray.b[1] - ray.a[1],
|
|
90
|
-
ray.b[2] - ray.a[2]
|
|
91
|
-
];
|
|
92
|
-
// Normalize the direction
|
|
93
|
-
const length = Math.sqrt(rayDirection[0] ** 2 + rayDirection[1] ** 2 + rayDirection[2] ** 2);
|
|
94
|
-
const normalizedDirection = [
|
|
95
|
-
rayDirection[0] / length,
|
|
96
|
-
rayDirection[1] / length,
|
|
97
|
-
rayDirection[2] / length
|
|
98
|
-
];
|
|
99
|
-
// Should point right (positive X), down (negative Y), and forward (negative Z, into scene)
|
|
100
|
-
expect(normalizedDirection[0]).toBeGreaterThan(0);
|
|
101
|
-
expect(normalizedDirection[1]).toBeLessThan(0);
|
|
102
|
-
expect(normalizedDirection[2]).toBeLessThan(0);
|
|
103
|
-
});
|
|
104
|
-
it("respects custom ray length", () => {
|
|
105
|
-
const camera = createTestCamera();
|
|
106
|
-
const canvasWidth = 1600;
|
|
107
|
-
const canvasHeight = 900;
|
|
108
|
-
const screenCenter = [canvasWidth / 2, canvasHeight / 2];
|
|
109
|
-
const customLength = 50;
|
|
110
|
-
// Compute the inverse view-projection matrix
|
|
111
|
-
const viewProjection = toViewProjection(camera);
|
|
112
|
-
const invViewProjection = Mat4x4.inverse(viewProjection);
|
|
113
|
-
const ray = screenToWorldRay(screenCenter, invViewProjection, canvasWidth, canvasHeight, customLength);
|
|
114
|
-
// Ray should start at near plane point
|
|
115
|
-
expect(ray.a[2]).toBeCloseTo(5, 1); // Near plane
|
|
116
|
-
// Ray should have the specified length
|
|
117
|
-
const rayDirection = [
|
|
118
|
-
ray.b[0] - ray.a[0],
|
|
119
|
-
ray.b[1] - ray.a[1],
|
|
120
|
-
ray.b[2] - ray.a[2]
|
|
121
|
-
];
|
|
122
|
-
const length = Math.sqrt(rayDirection[0] ** 2 + rayDirection[1] ** 2 + rayDirection[2] ** 2);
|
|
123
|
-
expect(length).toBeCloseTo(customLength, 1);
|
|
124
|
-
});
|
|
125
|
-
it("works with different camera positions", () => {
|
|
126
|
-
const camera = {
|
|
127
|
-
aspect: 16 / 9,
|
|
128
|
-
fieldOfView: Math.PI / 4,
|
|
129
|
-
nearPlane: 0.1,
|
|
130
|
-
farPlane: 100,
|
|
131
|
-
position: [10, 5, 15],
|
|
132
|
-
target: [0, 0, 0],
|
|
133
|
-
up: [0, 1, 0],
|
|
134
|
-
};
|
|
135
|
-
const canvasWidth = 1600;
|
|
136
|
-
const canvasHeight = 900;
|
|
137
|
-
const screenCenter = [canvasWidth / 2, canvasHeight / 2];
|
|
138
|
-
// Compute the inverse view-projection matrix
|
|
139
|
-
const viewProjection = toViewProjection(camera);
|
|
140
|
-
const invViewProjection = Mat4x4.inverse(viewProjection);
|
|
141
|
-
const ray = screenToWorldRay(screenCenter, invViewProjection, canvasWidth, canvasHeight);
|
|
142
|
-
// Ray should start at near plane point (not camera position)
|
|
143
|
-
// The actual values depend on the camera setup, so let's just check they're reasonable
|
|
144
|
-
expect(Math.abs(ray.a[0])).toBeLessThan(20);
|
|
145
|
-
expect(Math.abs(ray.a[1])).toBeLessThan(20);
|
|
146
|
-
expect(ray.a[2]).toBeCloseTo(15, 1); // Near plane should be close to camera z
|
|
147
|
-
// Ray should point toward the target
|
|
148
|
-
const rayDirection = [
|
|
149
|
-
ray.b[0] - ray.a[0],
|
|
150
|
-
ray.b[1] - ray.a[1],
|
|
151
|
-
ray.b[2] - ray.a[2]
|
|
152
|
-
];
|
|
153
|
-
// Find the closest point on the ray to the target
|
|
154
|
-
const dx = ray.b[0] - ray.a[0];
|
|
155
|
-
const dy = ray.b[1] - ray.a[1];
|
|
156
|
-
const dz = ray.b[2] - ray.a[2];
|
|
157
|
-
const t = ((camera.target[0] - ray.a[0]) * dx +
|
|
158
|
-
(camera.target[1] - ray.a[1]) * dy +
|
|
159
|
-
(camera.target[2] - ray.a[2]) * dz) / (dx * dx + dy * dy + dz * dz);
|
|
160
|
-
const closest = [
|
|
161
|
-
ray.a[0] + t * dx,
|
|
162
|
-
ray.a[1] + t * dy,
|
|
163
|
-
ray.a[2] + t * dz
|
|
164
|
-
];
|
|
165
|
-
const dist = Math.sqrt((closest[0] - camera.target[0]) ** 2 +
|
|
166
|
-
(closest[1] - camera.target[1]) ** 2 +
|
|
167
|
-
(closest[2] - camera.target[2]) ** 2);
|
|
168
|
-
expect(dist).toBeLessThan(1.0); // Ray passes close to the target
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
//# sourceMappingURL=screen-to-world-ray.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screen-to-world-ray.test.js","sourceRoot":"","sources":["../../../src/graphics/camera/screen-to-world-ray.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC9B,MAAM,gBAAgB,GAAG,GAAW,EAAE,CAAC,CAAC;QACpC,MAAM,EAAE,EAAE,GAAG,CAAC;QACd,WAAW,EAAE,IAAI,CAAC,EAAE,GAA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C,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CACrC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QAClC,MAAM,OAAO,GAAG;YACZ,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE;YACjB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE;YACjB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE;SACpB,CAAC;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAClB,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACpC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACpC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CACvC,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,iCAAiC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Mat4x4 } from "../../math/index.js";
|
|
2
|
-
export const toViewProjection = (camera) => {
|
|
3
|
-
const perspective = Mat4x4.perspective(camera.fieldOfView, camera.aspect, camera.nearPlane, camera.farPlane);
|
|
4
|
-
const lookAt = Mat4x4.lookAt(camera.position, camera.target, camera.up);
|
|
5
|
-
const viewProjection = Mat4x4.multiply(perspective, lookAt);
|
|
6
|
-
return viewProjection;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=to-view-projection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"to-view-projection.js","sourceRoot":"","sources":["../../../src/graphics/camera/to-view-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAG7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAU,EAAE;IACvD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7G,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IACxE,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC5D,OAAO,cAAc,CAAC;AAC1B,CAAC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Vec3 } from "../../math/index.js";
|
|
2
|
-
import type { Camera } from "./camera.js";
|
|
3
|
-
/**
|
|
4
|
-
* Converts a world space coordinate to screen space coordinates and depth.
|
|
5
|
-
*
|
|
6
|
-
* @param worldPosition - The 3D world position to convert
|
|
7
|
-
* @param camera - The camera resource containing position, target, FOV, etc.
|
|
8
|
-
* @param canvasWidth - The width of the canvas in pixels
|
|
9
|
-
* @param canvasHeight - The height of the canvas in pixels
|
|
10
|
-
* @returns Screen space coordinates and depth [x, y, depth] where (0,0) is top-left and (width,height) is bottom-right, depth is 0-1 (near=0, far=1) or 2 for behind camera
|
|
11
|
-
*/
|
|
12
|
-
export declare const worldToScreen: (worldPosition: Vec3, camera: Camera, canvasWidth: number, canvasHeight: number) => [number, number, number];
|