@webspatial/core-sdk 0.0.1 → 0.0.2
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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +112 -0
- package/dist/core/SpatialSession.d.ts.map +1 -1
- package/dist/core/SpatialSession.js +5 -1
- package/dist/core/component/SpatialModel3DComponent.d.ts +4 -4
- package/dist/core/component/SpatialModel3DComponent.d.ts.map +1 -1
- package/dist/core/component/index.d.ts +1 -1
- package/dist/core/component/index.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/core/SpatialSession.ts +7 -1
- package/src/core/component/SpatialModel3DComponent.ts +7 -7
- package/src/core/component/index.ts +1 -1
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Spatial Web
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# **Full API documentation**
|
|
2
|
+
|
|
3
|
+
* [API Docs](https://github.com/webspatial/webspatial.github.io/blob/main/docs/globals.md)
|
|
4
|
+
|
|
5
|
+
# **Introduction**
|
|
6
|
+
|
|
7
|
+
The core-sdk library is responsible for interacting with the target platforms native APIs to expose behavior not commonly found on the web.
|
|
8
|
+
|
|
9
|
+
# **Hello world example**
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
import { Spatial, SpatialHelper } from '@webspatial/core-sdk'
|
|
13
|
+
|
|
14
|
+
var main = async () => {
|
|
15
|
+
var spatial = new Spatial()
|
|
16
|
+
var versionInfo = "clientVersion:" + spatial.getClientVersion() + "\nnativeVersion:" + spatial.getNativeVersion() + "\nisSupported:" + spatial.isSupported()
|
|
17
|
+
|
|
18
|
+
let sh = SpatialHelper.instance!
|
|
19
|
+
if (sh) {
|
|
20
|
+
// Create a new window container
|
|
21
|
+
var container = await sh.session.createWindowContainer({ style: 'Volumetric' })
|
|
22
|
+
|
|
23
|
+
// Setup volume for the entity
|
|
24
|
+
var rootEntity = await sh.session.createEntity()
|
|
25
|
+
await rootEntity.setCoordinateSpace("Root")
|
|
26
|
+
rootEntity.setComponent(await sh.session.createViewComponent())
|
|
27
|
+
|
|
28
|
+
// Create a mesh. and add it tot the root volume
|
|
29
|
+
var box = await sh.shape.createShapeEntity("box")
|
|
30
|
+
await box.setParent(rootEntity)
|
|
31
|
+
|
|
32
|
+
// add the volume to the window
|
|
33
|
+
await container.setRootEntity(rootEntity)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
main()
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
# **Initialization**
|
|
40
|
+
|
|
41
|
+
Create a new spatial object which is the root entry point to the API. This object should be available in standard browsers as well as webspatial environments. This object can check client and native versions of the library and detect if webspatial is available in this setup.
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
var spatial = new Spatial()
|
|
45
|
+
if(spatial.isSupported()){
|
|
46
|
+
var session = spatial.requestSession()
|
|
47
|
+
if(session){
|
|
48
|
+
console.log("session supported and created")
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
# **Async/Await/Promises**
|
|
54
|
+
|
|
55
|
+
Due to the architecture of webspatial, the client library communicates to native code over a JS Bridge provided by the platform. Because of this, function calls may not be completed immediately. To accomidate this, the majority of webspatial api use [promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to keep track of completion. It is recommended you create an async main function to allow you to use the await syntax for app setup.
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
var main = async ()=>{
|
|
59
|
+
// Your code goes here
|
|
60
|
+
};
|
|
61
|
+
main()'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
# **WindowContainer**
|
|
65
|
+
|
|
66
|
+
To create a new WindowContainer (aka WindowGroup on apple vision pro)
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
var windowContainer = await session.createWindowContainer({ style: 'Volumetric' })
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Depending on if you want to display content as a panel or within a volume, you can choose to use "Plain" or "Volumetric" style.
|
|
73
|
+
|
|
74
|
+
# **Entity/Component api**
|
|
75
|
+
|
|
76
|
+
To start displaying content within a WindowContainer, you must create an entity.
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
// Create entity
|
|
80
|
+
var entity = await session.createEntity()
|
|
81
|
+
|
|
82
|
+
// Create component
|
|
83
|
+
await entity.setComponent(
|
|
84
|
+
await session.createViewComponent({ windowContainer: windowContainer }),
|
|
85
|
+
)
|
|
86
|
+
await entity.setCoordinateSpace('Root')
|
|
87
|
+
|
|
88
|
+
// Set root entity on the window container.
|
|
89
|
+
// Note the entity much have:
|
|
90
|
+
// - Root coordinate space
|
|
91
|
+
// - have a ViewComponent for Volumetric windowContainer
|
|
92
|
+
// - have a WindowComponent for Plain windowContainer
|
|
93
|
+
await windowContainer.setRootEntity(entity)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Entity maps to an object that will be displayed. Components tell how that object should be displayed.
|
|
97
|
+
You can find more examples here when you run the server locally:
|
|
98
|
+
|
|
99
|
+
* http://localhost:5173/src/docsWebsite/index.html?examplePath=webElement
|
|
100
|
+
|
|
101
|
+
# **Helper**
|
|
102
|
+
|
|
103
|
+
This library, similar to (webGL or webXR) may be a bit too verbose to use directly. You can use the helper we provide to do some common tasks such as opening a new webpage panel or use our higher level react API.
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
import { SpatialHelper } from '@webspatial/core-sdk'
|
|
107
|
+
SpatialHelper.instance.navigation.openPanel(
|
|
108
|
+
'https://www.npmjs.com/package/@webspatial/core-sdk',
|
|
109
|
+
{ resolution: { width: 600, height: 100 } },
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialSession.d.ts","sourceRoot":"","sources":["../../src/core/SpatialSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAMjE,OAAO,EACL,iBAAiB,EACjB,cAAc,EAEd,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,OAAO,EACL,mBAAmB,EACnB,sCAAsC,EACvC,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,aAAa,CAAA;AAGpB;;GAEG;AACH,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,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EAAE,EAAE;IASxD;;;SAGK;IACC,qBAAqB,CAAC,OAAO,CAAC,EAAE;QACpC,KAAK,EAAE,WAAW,CAAA;QAClB,eAAe,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;QAC/C,eAAe,CAAC,EAAE,sBAAsB,GAAG,IAAI,CAAA;KAChD;IAYD;;;;;;OAMG;IACG,YAAY,CAChB,KAAK,EAAE,WAAW,YAAU,EAC5B,GAAG,EAAE;QACH,SAAS,EAAE,cAAc,CAAA;KAC1B;IAKH;;;;OAIG;IACH,yBAAyB;IAIzB;;;OAGG;IACG,wBAAwB;IAgB9B;;;OAGG;IACG,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE;IAUvB;;;OAGG;IACG,KAAK,CAAC,GAAG,EAAE,MAAM;IAIvB;;;;OAIG;IACG,SAAS;iBACsC,GAAG;oBAAc,GAAG;;IAGzE;;OAEG;IACG,QAAQ,CAAC,eAAe,GAAE,MAA2C;IAI3E;;OAEG;IACG,2BAA2B;IAIjC,gCAAgC;IAC1B,kBAAkB;IAIxB,iCAAiC;IAC3B,qBAAqB;IAI3B,OAAO,CAAC,MAAM,CAAC,yBAAyB,CACD;IACvC;;;OAGG;IACG,2BAA2B;IAYjC,OAAO,CAAC,MAAM,CAAC,uBAAuB,CAAwC;IAE9E;;;;OAIG;IACH,yBAAyB;IAWzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,QAAQ;IAMxB;;;OAGG;IACG,mBAAmB;IAgCzB,cAAc;IACR,UAAU,CAAC,EAAE,EAAE,MAAM;IAoB3B,cAAc;IACR,UAAU,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;CAG3D"}
|
|
@@ -174,7 +174,11 @@ export class SpatialSession {
|
|
|
174
174
|
* @param msg mesage to log
|
|
175
175
|
*/
|
|
176
176
|
async log(...msg) {
|
|
177
|
-
await WebSpatial.sendCommand(new RemoteCommand('log', {
|
|
177
|
+
await WebSpatial.sendCommand(new RemoteCommand('log', {
|
|
178
|
+
logString: msg.map(x => {
|
|
179
|
+
return JSON.stringify(x);
|
|
180
|
+
}),
|
|
181
|
+
}));
|
|
178
182
|
}
|
|
179
183
|
/**
|
|
180
184
|
* @hidden
|
|
@@ -3,7 +3,7 @@ import { Vec3 } from '../SpatialTransform';
|
|
|
3
3
|
/**
|
|
4
4
|
* Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
|
|
5
5
|
*/
|
|
6
|
-
export type
|
|
6
|
+
export type SpatialModelDragEvent = {
|
|
7
7
|
eventType: 'dragstart' | 'dragend' | 'drag';
|
|
8
8
|
translation3D: Vec3;
|
|
9
9
|
startLocation3D: Vec3;
|
|
@@ -57,19 +57,19 @@ export declare class SpatialModel3DComponent extends EventSpatialComponent {
|
|
|
57
57
|
* @param dragEvent
|
|
58
58
|
*/
|
|
59
59
|
private _onDragStart?;
|
|
60
|
-
set onDragStart(callback: ((dragEvent:
|
|
60
|
+
set onDragStart(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
|
|
61
61
|
/**
|
|
62
62
|
* Callback fired when model was dragged
|
|
63
63
|
* @param dragEvent
|
|
64
64
|
*/
|
|
65
65
|
private _onDrag?;
|
|
66
|
-
set onDrag(callback: ((dragEvent:
|
|
66
|
+
set onDrag(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
|
|
67
67
|
/**
|
|
68
68
|
* Callback fired when model was dragged at the ending
|
|
69
69
|
* @param dragEvent
|
|
70
70
|
*/
|
|
71
71
|
private _onDragEnd?;
|
|
72
|
-
set onDragEnd(callback: ((dragEvent:
|
|
72
|
+
set onDragEnd(callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined);
|
|
73
73
|
private get enableDragEvent();
|
|
74
74
|
/**
|
|
75
75
|
* Callback fired when model was tapped
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpatialModel3DComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialModel3DComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"SpatialModel3DComponent.d.ts","sourceRoot":"","sources":["../../../src/core/component/SpatialModel3DComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE1C;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAA;IAC3C,aAAa,EAAE,IAAI,CAAA;IACnB,eAAe,EAAE,IAAI,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,EAAE,KAAK,CAAA;CACjB,CAAA;AAED;;GAEG;AACH,qBAAa,uBAAwB,SAAQ,qBAAqB;cAC7C,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAiC/C;;OAEG;IACG,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAM3C,iBAAiB,CAAC,cAAc,EAAE,IAAI;IAM5C;;;OAGG;IACG,UAAU,CAAC,OAAO,EAAE,MAAM;IAMhC;;;OAGG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,KAAK;IAMhD;;;;;OAKG;IACG,cAAc,CAAC,WAAW,EAAE,MAAM;IAMxC;;;OAGG;IACG,YAAY,CAAC,SAAS,EAAE,OAAO;IAMrC;;OAEG;IACI,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IAE7B;;;OAGG;IACI,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAA;IAEhD;;;OAGG;IACH,OAAO,CAAC,YAAY,CAAC,CAA4C;IACjE,IAAW,WAAW,CACpB,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,EAQnE;IAED;;;OAGG;IACH,OAAO,CAAC,OAAO,CAAC,CAA4C;IAC5D,IAAW,MAAM,CACf,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,EAQnE;IAED;;;OAGG;IACH,OAAO,CAAC,UAAU,CAAC,CAA4C;IAC/D,IAAW,SAAS,CAClB,QAAQ,EAAE,CAAC,CAAC,SAAS,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,EAQnE;IAED,OAAO,KAAK,eAAe,GAM1B;IAED;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,CAAY;IAC3B,IAAW,KAAK,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EAOlD;IAED,kDAAkD;IAClD,OAAO,CAAC,YAAY,CAAC,CAAY;IACjC,IAAW,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EAOxD;IAED,iDAAiD;IACjD,OAAO,CAAC,YAAY,CAAC,CAAY;IACjC,IAAW,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,EAOxD;CACF"}
|
|
@@ -3,5 +3,5 @@ export { SpatialWindowComponent, type BackgroundMaterialType, type StyleParam, t
|
|
|
3
3
|
export { SpatialInputComponent } from './SpatialInputComponent';
|
|
4
4
|
export { SpatialModelComponent } from './SpatialModelComponent';
|
|
5
5
|
export { SpatialViewComponent } from './SpatialViewComponent';
|
|
6
|
-
export { SpatialModel3DComponent, type
|
|
6
|
+
export { SpatialModel3DComponent, type SpatialModelDragEvent, } from './SpatialModel3DComponent';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EACL,uBAAuB,EACvB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/component/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EACL,sBAAsB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EACL,uBAAuB,EACvB,KAAK,qBAAqB,GAC3B,MAAM,2BAA2B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webspatial/core-sdk",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "this is runtime for webspatial",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
-
"build": "tsc",
|
|
12
|
-
"start": "tsc --watch",
|
|
13
|
-
"buildIife": "esbuild dist/index.js --outdir=dist/iife --minify --bundle --format=iife --global-name=webspatialRuntime",
|
|
14
|
-
"format": "npx prettier --write 'src/**/*.ts' 'src/**/*.tsx' || true",
|
|
15
|
-
"genDocs": "typedoc --plugin typedoc-plugin-markdown src/core/index.ts"
|
|
16
|
-
},
|
|
17
9
|
"repository": {
|
|
18
10
|
"type": "git",
|
|
19
11
|
"url": "git+https://github.com/webspatial/webspatial-sdk.git"
|
|
@@ -31,5 +23,13 @@
|
|
|
31
23
|
},
|
|
32
24
|
"dependencies": {
|
|
33
25
|
"loglevel": "^1.9.2"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "tsc -p ./tsconfig.json",
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"start": "tsc --watch",
|
|
31
|
+
"buildIife": "esbuild dist/index.js --outdir=dist/iife --minify --bundle --format=iife --global-name=webspatialRuntime",
|
|
32
|
+
"format": "npx prettier --write 'src/**/*.ts' 'src/**/*.tsx' || true",
|
|
33
|
+
"genDocs": "typedoc --plugin typedoc-plugin-markdown src/core/index.ts"
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
}
|
|
@@ -279,7 +279,13 @@ export class SpatialSession {
|
|
|
279
279
|
* @param msg mesage to log
|
|
280
280
|
*/
|
|
281
281
|
async log(...msg: any[]) {
|
|
282
|
-
await WebSpatial.sendCommand(
|
|
282
|
+
await WebSpatial.sendCommand(
|
|
283
|
+
new RemoteCommand('log', {
|
|
284
|
+
logString: msg.map(x => {
|
|
285
|
+
return JSON.stringify(x)
|
|
286
|
+
}),
|
|
287
|
+
}),
|
|
288
|
+
)
|
|
283
289
|
}
|
|
284
290
|
|
|
285
291
|
/**
|
|
@@ -5,7 +5,7 @@ import { Vec3 } from '../SpatialTransform'
|
|
|
5
5
|
/**
|
|
6
6
|
* Translate event, matching similar behavior to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/drag_event
|
|
7
7
|
*/
|
|
8
|
-
export type
|
|
8
|
+
export type SpatialModelDragEvent = {
|
|
9
9
|
eventType: 'dragstart' | 'dragend' | 'drag'
|
|
10
10
|
translation3D: Vec3
|
|
11
11
|
startLocation3D: Vec3
|
|
@@ -124,9 +124,9 @@ export class SpatialModel3DComponent extends EventSpatialComponent {
|
|
|
124
124
|
* Callback fired when model was dragged at the beginning
|
|
125
125
|
* @param dragEvent
|
|
126
126
|
*/
|
|
127
|
-
private _onDragStart?: (dragEvent:
|
|
127
|
+
private _onDragStart?: (dragEvent: SpatialModelDragEvent) => void
|
|
128
128
|
public set onDragStart(
|
|
129
|
-
callback: ((dragEvent:
|
|
129
|
+
callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,
|
|
130
130
|
) {
|
|
131
131
|
if (this._onDragStart !== callback) {
|
|
132
132
|
this._onDragStart = callback
|
|
@@ -140,9 +140,9 @@ export class SpatialModel3DComponent extends EventSpatialComponent {
|
|
|
140
140
|
* Callback fired when model was dragged
|
|
141
141
|
* @param dragEvent
|
|
142
142
|
*/
|
|
143
|
-
private _onDrag?: (dragEvent:
|
|
143
|
+
private _onDrag?: (dragEvent: SpatialModelDragEvent) => void
|
|
144
144
|
public set onDrag(
|
|
145
|
-
callback: ((dragEvent:
|
|
145
|
+
callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,
|
|
146
146
|
) {
|
|
147
147
|
if (this._onDrag !== callback) {
|
|
148
148
|
this._onDrag = callback
|
|
@@ -156,9 +156,9 @@ export class SpatialModel3DComponent extends EventSpatialComponent {
|
|
|
156
156
|
* Callback fired when model was dragged at the ending
|
|
157
157
|
* @param dragEvent
|
|
158
158
|
*/
|
|
159
|
-
private _onDragEnd?: (dragEvent:
|
|
159
|
+
private _onDragEnd?: (dragEvent: SpatialModelDragEvent) => void
|
|
160
160
|
public set onDragEnd(
|
|
161
|
-
callback: ((dragEvent:
|
|
161
|
+
callback: ((dragEvent: SpatialModelDragEvent) => void) | undefined,
|
|
162
162
|
) {
|
|
163
163
|
if (this._onDragEnd !== callback) {
|
|
164
164
|
this._onDragEnd = callback
|