@velumo/renderer-three 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +59 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +20 -0
- package/src/index.ts +159 -0
- package/tsconfig.json +10 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Layer } from "@velumo/core";
|
|
2
|
+
import type { CameraState, VelumoPlugin, LayerRenderer } from "@velumo/runtime";
|
|
3
|
+
export interface ThreeLikeVector3Like {
|
|
4
|
+
set(x: number, y: number, z: number): void;
|
|
5
|
+
}
|
|
6
|
+
export interface ThreeLikeCamera {
|
|
7
|
+
readonly position: ThreeLikeVector3Like;
|
|
8
|
+
zoom: number;
|
|
9
|
+
lookAt(x: number, y: number, z: number): void;
|
|
10
|
+
updateProjectionMatrix?(): void;
|
|
11
|
+
}
|
|
12
|
+
export interface ThreeLikeScene {
|
|
13
|
+
add(object: unknown): unknown;
|
|
14
|
+
remove(object: unknown): unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface ThreeLikeRendererCanvas {
|
|
17
|
+
readonly style: Record<string, string | undefined>;
|
|
18
|
+
}
|
|
19
|
+
export interface ThreeLikeRenderer {
|
|
20
|
+
readonly domElement: ThreeLikeRendererCanvas;
|
|
21
|
+
setSize(width: number, height: number): void;
|
|
22
|
+
render(scene: ThreeLikeScene, camera: ThreeLikeCamera): void;
|
|
23
|
+
dispose?(): void;
|
|
24
|
+
}
|
|
25
|
+
export interface ThreeFactories {
|
|
26
|
+
createScene(): ThreeLikeScene;
|
|
27
|
+
createCamera(): ThreeLikeCamera;
|
|
28
|
+
createRenderer(canvas: ThreeLikeRendererCanvas): ThreeLikeRenderer;
|
|
29
|
+
}
|
|
30
|
+
export interface ThreeLayerMountOptions {
|
|
31
|
+
readonly factories: ThreeFactories;
|
|
32
|
+
readonly canvas: ThreeLikeRendererCanvas;
|
|
33
|
+
readonly width?: number;
|
|
34
|
+
readonly height?: number;
|
|
35
|
+
readonly populateScene?: (scene: ThreeLikeScene) => void;
|
|
36
|
+
}
|
|
37
|
+
export interface ThreeLayerHandle {
|
|
38
|
+
readonly canvas: ThreeLikeRendererCanvas;
|
|
39
|
+
readonly scene: ThreeLikeScene;
|
|
40
|
+
readonly camera: ThreeLikeCamera;
|
|
41
|
+
readonly renderer: ThreeLikeRenderer;
|
|
42
|
+
update(state: CameraState): void;
|
|
43
|
+
dispose(): void;
|
|
44
|
+
}
|
|
45
|
+
export interface ThreeLayerPluginOptions {
|
|
46
|
+
readonly factories: ThreeFactories;
|
|
47
|
+
readonly createCanvas: () => ThreeLikeRendererCanvas;
|
|
48
|
+
readonly defaultWidth?: number;
|
|
49
|
+
readonly defaultHeight?: number;
|
|
50
|
+
readonly populateScene?: (scene: ThreeLikeScene) => void;
|
|
51
|
+
}
|
|
52
|
+
export interface ThreeLayerRendererContext {
|
|
53
|
+
readonly layer: Layer;
|
|
54
|
+
}
|
|
55
|
+
export type ThreeLayerRenderer = LayerRenderer<ThreeLayerRendererContext, ThreeLayerHandle>;
|
|
56
|
+
export declare const THREE_LAYER_TYPE = "three";
|
|
57
|
+
export declare function mountThreeLayer(options: ThreeLayerMountOptions): ThreeLayerHandle;
|
|
58
|
+
export declare function createThreeLayerPlugin(options: ThreeLayerPluginOptions): VelumoPlugin<ThreeLayerRendererContext, ThreeLayerHandle, unknown>;
|
|
59
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC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 800;
|
|
3
|
+
const DEFAULT_HEIGHT = 600;
|
|
4
|
+
const PLUGIN_ID = "velumo/renderer-three";
|
|
5
|
+
export function mountThreeLayer(options) {
|
|
6
|
+
const width = options.width ?? DEFAULT_WIDTH;
|
|
7
|
+
const height = options.height ?? DEFAULT_HEIGHT;
|
|
8
|
+
const canvas = options.canvas;
|
|
9
|
+
canvas.style.width = `${width}px`;
|
|
10
|
+
canvas.style.height = `${height}px`;
|
|
11
|
+
const scene = options.factories.createScene();
|
|
12
|
+
const camera = options.factories.createCamera();
|
|
13
|
+
const renderer = options.factories.createRenderer(canvas);
|
|
14
|
+
renderer.setSize(width, height);
|
|
15
|
+
if (options.populateScene !== undefined) {
|
|
16
|
+
options.populateScene(scene);
|
|
17
|
+
}
|
|
18
|
+
let disposed = false;
|
|
19
|
+
return {
|
|
20
|
+
canvas,
|
|
21
|
+
scene,
|
|
22
|
+
camera,
|
|
23
|
+
renderer,
|
|
24
|
+
update(state) {
|
|
25
|
+
if (disposed) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
camera.position.set(state.position.x, state.position.y, state.position.z);
|
|
29
|
+
camera.lookAt(state.target.x, state.target.y, state.target.z);
|
|
30
|
+
camera.zoom = state.zoom;
|
|
31
|
+
if (typeof camera.updateProjectionMatrix === "function") {
|
|
32
|
+
camera.updateProjectionMatrix();
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
dispose() {
|
|
36
|
+
if (disposed) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
disposed = true;
|
|
40
|
+
if (typeof renderer.dispose === "function") {
|
|
41
|
+
renderer.dispose();
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function isFinitePositive(value) {
|
|
47
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
48
|
+
}
|
|
49
|
+
export function createThreeLayerPlugin(options) {
|
|
50
|
+
return {
|
|
51
|
+
id: PLUGIN_ID,
|
|
52
|
+
setup({ registry }) {
|
|
53
|
+
const layerRenderer = (context) => {
|
|
54
|
+
const layerProps = context.layer.props;
|
|
55
|
+
const layerWidth = layerProps !== undefined && isFinitePositive(layerProps.width)
|
|
56
|
+
? layerProps.width
|
|
57
|
+
: (options.defaultWidth ?? DEFAULT_WIDTH);
|
|
58
|
+
const layerHeight = layerProps !== undefined && isFinitePositive(layerProps.height)
|
|
59
|
+
? layerProps.height
|
|
60
|
+
: (options.defaultHeight ?? DEFAULT_HEIGHT);
|
|
61
|
+
const canvas = options.createCanvas();
|
|
62
|
+
return mountThreeLayer({
|
|
63
|
+
factories: options.factories,
|
|
64
|
+
canvas,
|
|
65
|
+
width: layerWidth,
|
|
66
|
+
height: layerHeight,
|
|
67
|
+
...(options.populateScene !== undefined
|
|
68
|
+
? { populateScene: options.populateScene }
|
|
69
|
+
: {}),
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
registry.registerLayerRenderer(THREE_LAYER_TYPE, layerRenderer);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsEA,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAExC,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAE1C,MAAM,UAAU,eAAe,CAC7B,OAA+B;IAE/B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC;IAC7C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,cAAc,CAAC;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,KAAK,IAAI,C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AC;YACL,CAAC,CAAC;YACF,QAAQ,CAAC,qBAAqB,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;QAClE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../node_modules/typescript/lib/lib.scripthost.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/typescript/lib/lib.es2022.full.d.ts","../../core/dist/types.d.ts","../../core/dist/builders.d.ts","../../core/dist/manifest-schema.d.ts","../../core/dist/layout-validation.d.ts","../../core/dist/capabilities.d.ts","../../core/dist/validation.d.ts","../../core/dist/index.d.ts","../../runtime/dist/controller.d.ts","../../runtime/dist/hash.d.ts","../../runtime/dist/notes.d.ts","../../runtime/dist/registry.d.ts","../../runtime/dist/timeline.d.ts","../../runtime/dist/action-dispatcher.d.ts","../../runtime/dist/cue-dispatcher.d.ts","../../runtime/dist/camera.d.ts","../../runtime/dist/spatial.d.ts","../../runtime/dist/scene-player.d.ts","../../runtime/dist/theme-bundle.d.ts","../../runtime/dist/index.d.ts","../src/index.ts"],"fileIdsList":[[64],[64,65,66,67,68,69],[70,82],[70,71,74],[75],[70],[70,74,75,76],[71],[71,72,73,74,75,76,77,78,79,80,81],[70,71],[70,79],[70,75],[70,74]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"8a15b4607d9a499e2dbeed9ec0d3c0d7372c850b2d5f1fb259e8f6d41d468a84","impliedFormat":1},{"version":"26e0fe14baee4e127f4365d1ae0b276f400562e45e19e35fd2d4c296684715e6","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"2a2de5b9459b3fc44decd9ce6100b72f1b002ef523126c1d3d8b2a4a63d74d78","affectsGlobalScope":true,"impliedFormat":1},{"version":"f13f4b465c99041e912db5c44129a94588e1aafee35a50eab51044833f50b4ee","affectsGlobalScope":true,"impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"db9709688f82c9e5f65a119c64d835f906efe5f559d08b11642d56eb85b79357","affectsGlobalScope":true,"impliedFormat":1},{"version":"4b25b8c874acd1a4cf8444c3617e037d444d19080ac9f634b405583fd10ce1f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"37be57d7c90cf1f8112ee2636a068d8fd181289f82b744160ec56a7dc158a9f5","affectsGlobalScope":true,"impliedFormat":1},{"version":"a917a49ac94cd26b754ab84e113369a75d1a47a710661d7cd25e961cc797065f","affectsGlobalScope":true,"impliedFormat":1},{"version":"6d3261badeb7843d157ef3e6f5d1427d0eeb0af0cf9df84a62cfd29fd47ac86e","affectsGlobalScope":true,"impliedFormat":1},{"version":"195daca651dde22f2167ac0d0a05e215308119a3100f5e6268e8317d05a92526","affectsGlobalScope":true,"impliedFormat":1},{"version":"8b11e4285cd2bb164a4dc09248bdec69e9842517db4ca47c1ba913011e44ff2f","affectsGlobalScope":true,"impliedFormat":1},{"version":"0508571a52475e245b02bc50fa1394065a0a3d05277fbf5120c3784b85651799","affectsGlobalScope":true,"impliedFormat":1},{"version":"8f9af488f510c3015af3cc8c267a9e9d96c4dd38a1fdff0e11dc5a544711415b","affectsGlobalScope":true,"impliedFormat":1},{"version":"fc611fea8d30ea72c6bbfb599c9b4d393ce22e2f5bfef2172534781e7d138104","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},{"version":"01a30f9e8582b369075c0808df71121e6855cb06fd8d3d39511d9ebb66405205","impliedFormat":1},{"version":"8877805003603477c63696f8af86eb14be659de3027a597617e7a95ca9250a92","impliedFormat":99},{"version":"a2c4bcfeeaf83801774f8c21daf4c18b15fd9da4469e222a6708a58d235bb286","impliedFormat":99},{"version":"163a1497b249fb8ac3eac7710af6df75222a21b20434ec35d4489c85f18a397b","impliedFormat":99},{"version":"b1d091ebe44dc4eb7ba1535c76bcbf15df97a0cde19fda1bbd34e1503df10e95","impliedFormat":99},{"version":"baeb0570658dce9269d3a5dabb44a1e6e11d8712f45750ca80885fd0e2dab38e","impliedFormat":99},{"version":"def8ed8b7980dbad419047252c19812799dbf761e797d624a9a030fb318a27ee","impliedFormat":99},{"version":"09451d1bdb65b1b10cafbccc4c762f9181609881ba078e4aabfbb7c6d4effe17","impliedFormat":99},{"version":"4c26794e2a073e20bf40b3482be4f25fa4d6b83c8d4cdb7e3744d8401eef6c38","impliedFormat":99},{"version":"92692f5dcdd41d6cebb9785ebe83f6631e448d468c7e77f56c2fe6f8f32869ba","impliedFormat":99},{"version":"1093522585079cf706e859f4323d23832ef5b62b04805190bcba06614fc8bdcb","impliedFormat":99},{"version":"165426a72c724ac8b6c5068f64aeeedc976a31cddaf7bdb30689ca0e0e885885","impliedFormat":99},{"version":"9c6738ae625093663883e4694a79bd8d9c8ff79f0d0bb60b8d6e4ab39393b77d","impliedFormat":99},{"version":"f864cf8286ef0798ae6eb2808965e2038c10ffb940b196a3a6e6364fe534115f","impliedFormat":99},{"version":"d6628b767083fceffd23177e8c53e1348d372e5755c2880f8f2e958d7a6dbafc","impliedFormat":99},{"version":"efbeb4d5e4df969ce57b6fe98d6cabe2097cae2e0695b6ef85c77f7a8045e9a3","impliedFormat":99},{"version":"4bbc05996c36885d4da5e1d3b140fd16ee7121a4184843447a3bb47b240e3386","impliedFormat":99},{"version":"0eaeeda7b43eb04e6503115b59ea0fc0dcede7d39dc6651a1ae8ba94e5974b46","impliedFormat":99},{"version":"8cad53853f3c0a8f7391721d625259ba815e33c26139f59e08751fa38c326f6d","impliedFormat":99},{"version":"7af78eb71c547cc0353d89ca54074af736128b01e231ab5662e1300adc0e17fd","impliedFormat":99},{"version":"e27c503e9ad20dcf4b83bc5d7f31a642918a5a82c8a1b2181205aaf28d3bd318","signature":"326720f9d024cd8f8786690adc8bb793316bce78b4d46dcc72b4f955a5cdb0bc","impliedFormat":99}],"root":[83],"options":{"composite":true,"declaration":true,"declarationMap":true,"module":199,"outDir":"./","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9,"tsBuildInfoFile":"./tsconfig.tsbuildinfo"},"referencedMap":[[65,1],[68,1],[70,2],[67,1],[69,1],[83,3],[76,4],[78,5],[71,6],[77,7],[72,8],[82,9],[73,10],[74,6],[80,11],[79,12],[81,13],[75,6]],"latestChangedDtsFile":"./index.d.ts","version":"6.0.3"}
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@velumo/renderer-three",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@velumo/core": "0.0.0",
|
|
15
|
+
"@velumo/runtime": "0.0.0"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -b"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import type { Layer } from "@velumo/core";
|
|
2
|
+
import type { CameraState, VelumoPlugin, LayerRenderer } from "@velumo/runtime";
|
|
3
|
+
|
|
4
|
+
export interface ThreeLikeVector3Like {
|
|
5
|
+
set(x: number, y: number, z: number): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ThreeLikeCamera {
|
|
9
|
+
readonly position: ThreeLikeVector3Like;
|
|
10
|
+
zoom: number;
|
|
11
|
+
lookAt(x: number, y: number, z: number): void;
|
|
12
|
+
updateProjectionMatrix?(): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ThreeLikeScene {
|
|
16
|
+
add(object: unknown): unknown;
|
|
17
|
+
remove(object: unknown): unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ThreeLikeRendererCanvas {
|
|
21
|
+
readonly style: Record<string, string | undefined>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ThreeLikeRenderer {
|
|
25
|
+
readonly domElement: ThreeLikeRendererCanvas;
|
|
26
|
+
setSize(width: number, height: number): void;
|
|
27
|
+
render(scene: ThreeLikeScene, camera: ThreeLikeCamera): void;
|
|
28
|
+
dispose?(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ThreeFactories {
|
|
32
|
+
createScene(): ThreeLikeScene;
|
|
33
|
+
createCamera(): ThreeLikeCamera;
|
|
34
|
+
createRenderer(canvas: ThreeLikeRendererCanvas): ThreeLikeRenderer;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ThreeLayerMountOptions {
|
|
38
|
+
readonly factories: ThreeFactories;
|
|
39
|
+
readonly canvas: ThreeLikeRendererCanvas;
|
|
40
|
+
readonly width?: number;
|
|
41
|
+
readonly height?: number;
|
|
42
|
+
readonly populateScene?: (scene: ThreeLikeScene) => void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ThreeLayerHandle {
|
|
46
|
+
readonly canvas: ThreeLikeRendererCanvas;
|
|
47
|
+
readonly scene: ThreeLikeScene;
|
|
48
|
+
readonly camera: ThreeLikeCamera;
|
|
49
|
+
readonly renderer: ThreeLikeRenderer;
|
|
50
|
+
update(state: CameraState): void;
|
|
51
|
+
dispose(): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ThreeLayerPluginOptions {
|
|
55
|
+
readonly factories: ThreeFactories;
|
|
56
|
+
readonly createCanvas: () => ThreeLikeRendererCanvas;
|
|
57
|
+
readonly defaultWidth?: number;
|
|
58
|
+
readonly defaultHeight?: number;
|
|
59
|
+
readonly populateScene?: (scene: ThreeLikeScene) => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ThreeLayerRendererContext {
|
|
63
|
+
readonly layer: Layer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type ThreeLayerRenderer = LayerRenderer<
|
|
67
|
+
ThreeLayerRendererContext,
|
|
68
|
+
ThreeLayerHandle
|
|
69
|
+
>;
|
|
70
|
+
|
|
71
|
+
export const THREE_LAYER_TYPE = "three";
|
|
72
|
+
|
|
73
|
+
const DEFAULT_WIDTH = 800;
|
|
74
|
+
const DEFAULT_HEIGHT = 600;
|
|
75
|
+
const PLUGIN_ID = "velumo/renderer-three";
|
|
76
|
+
|
|
77
|
+
export function mountThreeLayer(
|
|
78
|
+
options: ThreeLayerMountOptions,
|
|
79
|
+
): ThreeLayerHandle {
|
|
80
|
+
const width = options.width ?? DEFAULT_WIDTH;
|
|
81
|
+
const height = options.height ?? DEFAULT_HEIGHT;
|
|
82
|
+
const canvas = options.canvas;
|
|
83
|
+
canvas.style.width = `${width}px`;
|
|
84
|
+
canvas.style.height = `${height}px`;
|
|
85
|
+
|
|
86
|
+
const scene = options.factories.createScene();
|
|
87
|
+
const camera = options.factories.createCamera();
|
|
88
|
+
const renderer = options.factories.createRenderer(canvas);
|
|
89
|
+
renderer.setSize(width, height);
|
|
90
|
+
|
|
91
|
+
if (options.populateScene !== undefined) {
|
|
92
|
+
options.populateScene(scene);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let disposed = false;
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
canvas,
|
|
99
|
+
scene,
|
|
100
|
+
camera,
|
|
101
|
+
renderer,
|
|
102
|
+
update(state: CameraState): void {
|
|
103
|
+
if (disposed) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
camera.position.set(state.position.x, state.position.y, state.position.z);
|
|
107
|
+
camera.lookAt(state.target.x, state.target.y, state.target.z);
|
|
108
|
+
camera.zoom = state.zoom;
|
|
109
|
+
if (typeof camera.updateProjectionMatrix === "function") {
|
|
110
|
+
camera.updateProjectionMatrix();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
dispose(): void {
|
|
114
|
+
if (disposed) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
disposed = true;
|
|
118
|
+
if (typeof renderer.dispose === "function") {
|
|
119
|
+
renderer.dispose();
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function isFinitePositive(value: unknown): value is number {
|
|
126
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function createThreeLayerPlugin(
|
|
130
|
+
options: ThreeLayerPluginOptions,
|
|
131
|
+
): VelumoPlugin<ThreeLayerRendererContext, ThreeLayerHandle, unknown> {
|
|
132
|
+
return {
|
|
133
|
+
id: PLUGIN_ID,
|
|
134
|
+
setup({ registry }) {
|
|
135
|
+
const layerRenderer: ThreeLayerRenderer = (context) => {
|
|
136
|
+
const layerProps = context.layer.props;
|
|
137
|
+
const layerWidth =
|
|
138
|
+
layerProps !== undefined && isFinitePositive(layerProps.width)
|
|
139
|
+
? layerProps.width
|
|
140
|
+
: (options.defaultWidth ?? DEFAULT_WIDTH);
|
|
141
|
+
const layerHeight =
|
|
142
|
+
layerProps !== undefined && isFinitePositive(layerProps.height)
|
|
143
|
+
? layerProps.height
|
|
144
|
+
: (options.defaultHeight ?? DEFAULT_HEIGHT);
|
|
145
|
+
const canvas = options.createCanvas();
|
|
146
|
+
return mountThreeLayer({
|
|
147
|
+
factories: options.factories,
|
|
148
|
+
canvas,
|
|
149
|
+
width: layerWidth,
|
|
150
|
+
height: layerHeight,
|
|
151
|
+
...(options.populateScene !== undefined
|
|
152
|
+
? { populateScene: options.populateScene }
|
|
153
|
+
: {}),
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
registry.registerLayerRenderer(THREE_LAYER_TYPE, layerRenderer);
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
package/tsconfig.json
ADDED