@shapediver/viewer.rendering-engine.canvas-engine 3.3.4 → 3.3.7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/viewer.rendering-engine.canvas-engine",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
"test": "__tests__"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"dist",
|
|
14
|
-
"src",
|
|
15
13
|
"package.json",
|
|
14
|
+
"dist/",
|
|
16
15
|
"README.md",
|
|
17
|
-
"
|
|
16
|
+
"LICENSE"
|
|
18
17
|
],
|
|
19
18
|
"publishConfig": {
|
|
20
19
|
"access": "public"
|
|
@@ -39,9 +38,9 @@
|
|
|
39
38
|
"testEnvironment": "jsdom"
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
42
|
-
"@shapediver/viewer.rendering-engine.rendering-engine": "3.3.
|
|
43
|
-
"@shapediver/viewer.shared.services": "3.3.
|
|
41
|
+
"@shapediver/viewer.rendering-engine.rendering-engine": "3.3.7",
|
|
42
|
+
"@shapediver/viewer.shared.services": "3.3.7",
|
|
44
43
|
"gl-matrix": "3.3.0"
|
|
45
44
|
},
|
|
46
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "112787d5c5226cca5e89d08102d0b1a3dd4a1d71"
|
|
47
46
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ICanvas } from '../interfaces/ICanvas';
|
|
2
|
-
|
|
3
|
-
export class Canvas implements ICanvas {
|
|
4
|
-
// #region Constructors (1)
|
|
5
|
-
|
|
6
|
-
constructor(private readonly _id: string, private readonly _originalDefinition?: HTMLCanvasElement | string, private readonly _canvasElement?: HTMLCanvasElement) {
|
|
7
|
-
if (this._originalDefinition && this._originalDefinition instanceof HTMLCanvasElement)
|
|
8
|
-
this._originalDefinition = <HTMLCanvasElement>this._originalDefinition.cloneNode(true);
|
|
9
|
-
|
|
10
|
-
if (!_canvasElement) {
|
|
11
|
-
this._canvasElement = document.createElement('canvas') as HTMLCanvasElement;
|
|
12
|
-
this._canvasElement.id = this._id;
|
|
13
|
-
} else {
|
|
14
|
-
this._canvasElement = <HTMLCanvasElement>_canvasElement;
|
|
15
|
-
}
|
|
16
|
-
this._canvasElement.style.touchAction = 'none';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// #endregion Constructors (1)
|
|
20
|
-
|
|
21
|
-
// #region Public Accessors (2)
|
|
22
|
-
|
|
23
|
-
public get canvasElement(): HTMLCanvasElement {
|
|
24
|
-
return <HTMLCanvasElement>this._canvasElement;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public get id(): string {
|
|
28
|
-
return this._id;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// #endregion Public Accessors (2)
|
|
32
|
-
|
|
33
|
-
// #region Public Methods (1)
|
|
34
|
-
|
|
35
|
-
public reset() {
|
|
36
|
-
const parent = this._canvasElement?.parentElement;
|
|
37
|
-
parent?.removeChild(this._canvasElement!);
|
|
38
|
-
|
|
39
|
-
if (this._originalDefinition instanceof HTMLCanvasElement) {
|
|
40
|
-
parent?.appendChild(this._canvasElement!);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// #endregion Public Methods (1)
|
|
45
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { UuidGenerator } from '@shapediver/viewer.shared.services'
|
|
2
|
-
|
|
3
|
-
import { Canvas } from './Canvas'
|
|
4
|
-
import { ICanvasEngine } from '../interfaces/ICanvasEngine'
|
|
5
|
-
import { ICanvas } from '../interfaces/ICanvas'
|
|
6
|
-
|
|
7
|
-
export class CanvasEngine implements ICanvasEngine {
|
|
8
|
-
// #region Properties (3)
|
|
9
|
-
|
|
10
|
-
private readonly _canvasDictionary: {
|
|
11
|
-
[key: string]: Canvas
|
|
12
|
-
} = {};
|
|
13
|
-
|
|
14
|
-
private static _instance: CanvasEngine;
|
|
15
|
-
|
|
16
|
-
protected readonly _uuidGenerator: UuidGenerator = UuidGenerator.instance;
|
|
17
|
-
|
|
18
|
-
// #endregion Properties (3)
|
|
19
|
-
|
|
20
|
-
// #region Public Static Accessors (1)
|
|
21
|
-
|
|
22
|
-
public static get instance() {
|
|
23
|
-
return this._instance || (this._instance = new this());
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// #endregion Public Static Accessors (1)
|
|
27
|
-
|
|
28
|
-
// #region Public Methods (2)
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Creates a canvas object that could in the future be expanded to hold more information
|
|
32
|
-
* The definition of the canvas can be:
|
|
33
|
-
* - empty: A canvas is created with an unique ID.
|
|
34
|
-
* - string:
|
|
35
|
-
* - If a canvas with this ID was created, this canvas is returned.
|
|
36
|
-
* - If there is an HTMLCanvasElement in the document with this ID, this is used.
|
|
37
|
-
* - If there is no HTMLElement found in the document with this ID, a canvas with ID will be created.
|
|
38
|
-
* - HTMLCanvasElement: A Canvas Object will be created with this element. If there is no ID, one will be generated.
|
|
39
|
-
*
|
|
40
|
-
* @param canvasDefinition the definition of this canvas
|
|
41
|
-
*/
|
|
42
|
-
public createCanvasObject(canvasDefinition?: string | HTMLCanvasElement, storageId?: string): string {
|
|
43
|
-
storageId = storageId !== undefined && this._uuidGenerator.validate(storageId) ? storageId : this._uuidGenerator.create();
|
|
44
|
-
|
|
45
|
-
if (canvasDefinition instanceof HTMLCanvasElement) {
|
|
46
|
-
// a canvas was provided
|
|
47
|
-
const canvasElement = (<HTMLCanvasElement>canvasDefinition);
|
|
48
|
-
if (!canvasElement.id)
|
|
49
|
-
canvasElement.id = this._uuidGenerator.create();
|
|
50
|
-
this._canvasDictionary[storageId] = new Canvas(canvasElement.id, canvasDefinition, canvasElement);
|
|
51
|
-
return storageId;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (canvasDefinition) {
|
|
55
|
-
const id: string = canvasDefinition;
|
|
56
|
-
const canvasElement = document.getElementById(id);
|
|
57
|
-
|
|
58
|
-
for (let canvasId in this._canvasDictionary)
|
|
59
|
-
if (this._canvasDictionary[canvasId].id === id)
|
|
60
|
-
return canvasId;
|
|
61
|
-
|
|
62
|
-
if (canvasElement instanceof HTMLCanvasElement) {
|
|
63
|
-
// id of a canvas was provided
|
|
64
|
-
this._canvasDictionary[storageId] = new Canvas(id, canvasDefinition, canvasElement);
|
|
65
|
-
return storageId;
|
|
66
|
-
} else if(!canvasElement) {
|
|
67
|
-
// no HTMLElement could be found, create Canvas with the id
|
|
68
|
-
this._canvasDictionary[storageId] = new Canvas(id, canvasDefinition);
|
|
69
|
-
return storageId;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
this._canvasDictionary[storageId] = new Canvas(storageId, canvasDefinition);
|
|
74
|
-
return storageId;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public getCanvas(storageId: string): ICanvas {
|
|
78
|
-
return this._canvasDictionary[storageId];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// #endregion Public Methods (2)
|
|
82
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Canvas } from './implementation/Canvas'
|
|
2
|
-
import { CanvasEngine } from './implementation/CanvasEngine'
|
|
3
|
-
import { ICanvas } from './interfaces/ICanvas'
|
|
4
|
-
import { ICanvasEngine } from './interfaces/ICanvasEngine'
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
CanvasEngine, Canvas, ICanvasEngine, ICanvas
|
|
8
|
-
}
|
package/tsconfig.json
DELETED