mirage-engine 0.1.1 → 0.2.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/LICENSE +21 -0
- package/README.md +20 -0
- package/dist/dev/main.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/mirage-engine.js +110 -91
- package/dist/mirage-engine.umd.js +1 -1
- package/dist/{core → src/core}/Syncer.d.ts +1 -0
- package/dist/src/dom/Extractor.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/{renderer → src/renderer}/Renderer.d.ts +3 -2
- package/dist/{types → src/types}/index.d.ts +7 -0
- package/package.json +5 -1
- package/dist/dom/Extractor.d.ts +0 -2
- /package/dist/{core → src/core}/Mirage.d.ts +0 -0
- /package/dist/{renderer → src/renderer}/DomProjector.d.ts +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 siwoo lee
|
|
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,20 @@
|
|
|
1
|
+
# MirageEngine
|
|
2
|
+
|
|
3
|
+
> **An engine that mirrors HTML DOM elements to a WebGL scene in real-time.**
|
|
4
|
+
|
|
5
|
+
MirageEngine directly mirrors HTML DOM elements to WebGL objects. It observes DOM mutations and synchronizes position, style, and content in real-time, allowing standard HTML elements to exist within a WebGL context.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install mirage-engine
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Mirage } from 'mirage-engine';
|
|
17
|
+
|
|
18
|
+
const engine = new Mirage("#target");
|
|
19
|
+
engine.start();
|
|
20
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './src/index'
|
|
2
|
+
export {}
|
package/dist/mirage-engine.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import * as
|
|
5
|
-
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var E = (n, e, t) => e in n ? D(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var s = (n, e, t) => (E(n, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import * as a from "three";
|
|
5
|
+
const m = 0, u = 1, p = 2, y = 8;
|
|
6
|
+
class R {
|
|
6
7
|
constructor() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this
|
|
8
|
+
s(this, "canvas");
|
|
9
|
+
s(this, "scene");
|
|
10
|
+
s(this, "camera");
|
|
11
|
+
s(this, "renderer");
|
|
12
|
+
s(this, "renderOrder", 0);
|
|
13
|
+
s(this, "meshMap", /* @__PURE__ */ new Map());
|
|
14
|
+
this.canvas = document.createElement("canvas"), this.scene = new a.Scene();
|
|
13
15
|
const e = window.innerWidth, t = window.innerHeight;
|
|
14
|
-
this.camera = new
|
|
16
|
+
this.camera = new a.OrthographicCamera(
|
|
15
17
|
e / -2,
|
|
16
18
|
e / 2,
|
|
17
19
|
t / 2,
|
|
18
20
|
t / -2,
|
|
19
21
|
1,
|
|
20
22
|
1e3
|
|
21
|
-
), this.camera.position.z = 100, this.renderer = new
|
|
23
|
+
), this.camera.position.z = 100, this.renderer = new a.WebGLRenderer({
|
|
22
24
|
canvas: this.canvas,
|
|
23
25
|
alpha: !0
|
|
24
26
|
}), this.renderer.setSize(e, t);
|
|
@@ -36,102 +38,119 @@ class S {
|
|
|
36
38
|
setSize(e, t) {
|
|
37
39
|
this.renderer.setSize(e, t), this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
syncScene(e) {
|
|
42
|
+
this.renderOrder = 0;
|
|
43
|
+
const t = /* @__PURE__ */ new Set();
|
|
44
|
+
this.reconcileNode(e, t);
|
|
45
|
+
for (const [r, i] of this.meshMap.entries())
|
|
46
|
+
t.has(r) || (this.scene.remove(i), i.geometry.dispose(), i.material instanceof a.Material && i.material.dispose(), this.meshMap.delete(r));
|
|
42
47
|
}
|
|
43
|
-
|
|
48
|
+
reconcileNode(e, t) {
|
|
44
49
|
if (e.type === "BOX") {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const a = s.match(/[\d.]+/g);
|
|
54
|
-
if (a && a.length >= 4) {
|
|
55
|
-
const g = a[0], y = a[1], T = a[2];
|
|
56
|
-
n = parseFloat(a[3]), o = `rgb(${g}, ${y}, ${T})`;
|
|
57
|
-
}
|
|
50
|
+
t.add(e.element);
|
|
51
|
+
let r = this.meshMap.get(e.element);
|
|
52
|
+
if (r)
|
|
53
|
+
console.log("[V2] 기존 매쉬 재사용:", e.element);
|
|
54
|
+
else {
|
|
55
|
+
console.log("[V2] 매쉬 신규 생성:", e.element);
|
|
56
|
+
const i = new a.PlaneGeometry(1, 1), o = new a.MeshBasicMaterial({ transparent: !0 });
|
|
57
|
+
r = new a.Mesh(i, o), this.scene.add(r), this.meshMap.set(e.element, r);
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
transparent: c < 1
|
|
63
|
-
}), l = new h.Mesh(t, d), u = this.renderer.domElement.width, f = this.renderer.domElement.height, w = 1e-3;
|
|
64
|
-
this.renderOrder++, l.position.set(
|
|
65
|
-
e.rect.x - u / 2 + e.rect.width / 2,
|
|
66
|
-
-e.rect.y + f / 2 - e.rect.height / 2,
|
|
67
|
-
e.styles.zIndex + this.renderOrder * w
|
|
68
|
-
), this.scene.add(l);
|
|
69
|
-
for (const a of e.children)
|
|
70
|
-
this.buildScene(a);
|
|
59
|
+
this.updateMeshProperties(r, e);
|
|
60
|
+
for (const i of e.children)
|
|
61
|
+
this.reconcileNode(i, t);
|
|
71
62
|
}
|
|
72
63
|
}
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
updateMeshProperties(e, t) {
|
|
65
|
+
console.log(
|
|
66
|
+
`[V2] 업데이트 중인 매쉬 ID: ${e.uuid}, 마스크: ${t.dirtyMask}`
|
|
67
|
+
);
|
|
68
|
+
const { rect: r, styles: i } = t, o = this.renderer.domElement.width, l = this.renderer.domElement.height;
|
|
69
|
+
e.scale.set(r.width, r.height, 1);
|
|
70
|
+
const g = 1e-3;
|
|
71
|
+
this.renderOrder++, e.position.set(
|
|
72
|
+
r.x - o / 2 + r.width / 2,
|
|
73
|
+
-r.y + l / 2 - r.height / 2,
|
|
74
|
+
i.zIndex + this.renderOrder * g
|
|
75
|
+
);
|
|
76
|
+
const c = e.material, d = i.backgroundColor;
|
|
77
|
+
let f = d, w = 1;
|
|
78
|
+
if (d === "transparent" || d === "rgba(0, 0, 0, 0)")
|
|
79
|
+
f = "#ffffff", w = 0;
|
|
80
|
+
else if (d.startsWith("rgba")) {
|
|
81
|
+
const h = d.match(/[\d.]+/g);
|
|
82
|
+
if (h && h.length >= 4) {
|
|
83
|
+
const M = h[0], b = h[1], S = h[2];
|
|
84
|
+
w = parseFloat(h[3]), f = `rgb(${M}, ${b}, ${S})`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const T = i.opacity * w;
|
|
88
|
+
c.color.set(f), c.opacity = T, c.transparent = T < 1, t.dirtyMask & u && console.log(" -> 위치/크기만 업데이트됨"), t.dirtyMask & p && console.log(" -> 스타일만 업데이트됨");
|
|
75
89
|
}
|
|
76
90
|
render() {
|
|
77
91
|
this.renderer.render(this.scene, this.camera);
|
|
78
92
|
}
|
|
79
93
|
}
|
|
80
|
-
function
|
|
81
|
-
if (
|
|
94
|
+
function v(n, e = u | p) {
|
|
95
|
+
if (n.tagName === "SCRIPT" || n.tagName === "STYLE")
|
|
82
96
|
return null;
|
|
83
|
-
const
|
|
84
|
-
x:
|
|
85
|
-
y:
|
|
86
|
-
width:
|
|
87
|
-
height:
|
|
88
|
-
},
|
|
89
|
-
backgroundColor:
|
|
90
|
-
opacity: parseFloat(
|
|
91
|
-
zIndex: parseInt(
|
|
92
|
-
},
|
|
93
|
-
for (const
|
|
94
|
-
const
|
|
95
|
-
|
|
97
|
+
const t = n.getBoundingClientRect(), r = {
|
|
98
|
+
x: t.x + window.scrollX,
|
|
99
|
+
y: t.y + window.scrollY,
|
|
100
|
+
width: t.width,
|
|
101
|
+
height: t.height
|
|
102
|
+
}, i = window.getComputedStyle(n), o = {
|
|
103
|
+
backgroundColor: i.backgroundColor,
|
|
104
|
+
opacity: parseFloat(i.opacity),
|
|
105
|
+
zIndex: parseInt(i.zIndex, 10) || 0
|
|
106
|
+
}, l = [];
|
|
107
|
+
for (const g of n.children) {
|
|
108
|
+
const c = v(g);
|
|
109
|
+
c && l.push(c);
|
|
96
110
|
}
|
|
97
111
|
return {
|
|
98
112
|
type: "BOX",
|
|
99
|
-
|
|
113
|
+
element: n,
|
|
114
|
+
rect: r,
|
|
100
115
|
styles: o,
|
|
101
|
-
|
|
116
|
+
dirtyMask: e,
|
|
117
|
+
children: l
|
|
102
118
|
};
|
|
103
119
|
}
|
|
104
|
-
class
|
|
120
|
+
class C {
|
|
105
121
|
constructor(e, t) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
s(this, "target");
|
|
123
|
+
s(this, "renderer");
|
|
124
|
+
s(this, "observer");
|
|
125
|
+
s(this, "isDomDirty", !1);
|
|
126
|
+
s(this, "isRunning", !1);
|
|
127
|
+
s(this, "pendingMask", m);
|
|
128
|
+
s(this, "mutationTimer", null);
|
|
129
|
+
s(this, "cssTimer", null);
|
|
130
|
+
s(this, "onTransitionFinished", (e) => {
|
|
131
|
+
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingMask |= u | p, this.cssTimer = window.setTimeout(() => {
|
|
115
132
|
this.isDomDirty = !0, this.cssTimer = null;
|
|
116
133
|
}, 50));
|
|
117
134
|
});
|
|
118
|
-
|
|
135
|
+
s(this, "onWindowResize", () => {
|
|
119
136
|
this.renderer.setSize(window.innerWidth, window.innerHeight), this.isDomDirty = !0;
|
|
120
137
|
});
|
|
121
|
-
|
|
138
|
+
s(this, "renderLoop", () => {
|
|
122
139
|
this.isRunning && (this.isDomDirty && this.forceUpdateScene(), this.renderer.render(), requestAnimationFrame(this.renderLoop));
|
|
123
140
|
});
|
|
124
|
-
this.target = e, this.renderer = t, this.observer = new MutationObserver((
|
|
125
|
-
let
|
|
126
|
-
for (const
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
this.
|
|
130
|
-
|
|
141
|
+
this.target = e, this.renderer = t, this.observer = new MutationObserver((r) => {
|
|
142
|
+
let i = m;
|
|
143
|
+
for (const o of r)
|
|
144
|
+
o.type === "childList" ? i |= y : o.type === "attributes" && (o.attributeName === "style" || o.attributeName === "class") && (i |= u | p);
|
|
145
|
+
if (i !== m) {
|
|
146
|
+
if (this.pendingMask |= i, i & y) {
|
|
147
|
+
this.clearTimers(), console.log("Structural Change detected"), this.isDomDirty = !0;
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
this.mutationTimer && clearTimeout(this.mutationTimer), this.mutationTimer = window.setTimeout(() => {
|
|
151
|
+
this.mutationTimer = null, this.isDomDirty = !0;
|
|
152
|
+
}, 200);
|
|
131
153
|
}
|
|
132
|
-
n && (this.mutationTimer && clearTimeout(this.mutationTimer), this.mutationTimer = window.setTimeout(() => {
|
|
133
|
-
this.mutationTimer = null, this.isDomDirty = !0;
|
|
134
|
-
}, 200));
|
|
135
154
|
});
|
|
136
155
|
}
|
|
137
156
|
start() {
|
|
@@ -150,19 +169,19 @@ class b {
|
|
|
150
169
|
}
|
|
151
170
|
forceUpdateScene() {
|
|
152
171
|
this.isDomDirty = !1;
|
|
153
|
-
const e =
|
|
154
|
-
e && this.renderer.syncScene(e);
|
|
172
|
+
const e = v(this.target, this.pendingMask);
|
|
173
|
+
e && this.renderer.syncScene(e), this.pendingMask = m;
|
|
155
174
|
}
|
|
156
175
|
}
|
|
157
|
-
class
|
|
176
|
+
class k {
|
|
158
177
|
constructor(e) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
178
|
+
s(this, "renderer");
|
|
179
|
+
s(this, "syncer");
|
|
180
|
+
s(this, "target");
|
|
162
181
|
const t = document.querySelector(e);
|
|
163
182
|
if (!t)
|
|
164
183
|
throw new Error(`[Mirage] Element not found: ${e}`);
|
|
165
|
-
this.target = t, this.renderer = new
|
|
184
|
+
this.target = t, this.renderer = new R(), this.renderer.mount(document.body), this.syncer = new C(this.target, this.renderer);
|
|
166
185
|
}
|
|
167
186
|
start() {
|
|
168
187
|
this.syncer.start();
|
|
@@ -172,5 +191,5 @@ class C {
|
|
|
172
191
|
}
|
|
173
192
|
}
|
|
174
193
|
export {
|
|
175
|
-
|
|
194
|
+
k as Mirage
|
|
176
195
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.MirageEngine={},o.THREE))})(this,function(o,a){"use strict";var z=Object.defineProperty;var L=(o,a,h)=>a in o?z(o,a,{enumerable:!0,configurable:!0,writable:!0,value:h}):o[a]=h;var s=(o,a,h)=>(L(o,typeof a!="symbol"?a+"":a,h),h);function h(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const d=h(a),f=0,p=1,g=2,b=8;class E{constructor(){s(this,"canvas");s(this,"scene");s(this,"camera");s(this,"renderer");s(this,"renderOrder",0);s(this,"meshMap",new Map);this.canvas=document.createElement("canvas"),this.scene=new d.Scene;const e=window.innerWidth,t=window.innerHeight;this.camera=new d.OrthographicCamera(e/-2,e/2,t/2,t/-2,1,1e3),this.camera.position.z=100,this.renderer=new d.WebGLRenderer({canvas:this.canvas,alpha:!0}),this.renderer.setSize(e,t)}mount(e){e.appendChild(this.canvas)}dispose(){try{this.renderer.dispose()}catch{}this.canvas.parentElement&&this.canvas.parentElement.removeChild(this.canvas)}setSize(e,t){this.renderer.setSize(e,t),this.camera.left=e/-2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=t/-2,this.camera.updateProjectionMatrix()}syncScene(e){this.renderOrder=0;const t=new Set;this.reconcileNode(e,t);for(const[i,r]of this.meshMap.entries())t.has(i)||(this.scene.remove(r),r.geometry.dispose(),r.material instanceof d.Material&&r.material.dispose(),this.meshMap.delete(i))}reconcileNode(e,t){if(e.type==="BOX"){t.add(e.element);let i=this.meshMap.get(e.element);if(i)console.log("[V2] 기존 매쉬 재사용:",e.element);else{console.log("[V2] 매쉬 신규 생성:",e.element);const r=new d.PlaneGeometry(1,1),c=new d.MeshBasicMaterial({transparent:!0});i=new d.Mesh(r,c),this.scene.add(i),this.meshMap.set(e.element,i)}this.updateMeshProperties(i,e);for(const r of e.children)this.reconcileNode(r,t)}}updateMeshProperties(e,t){console.log(`[V2] 업데이트 중인 매쉬 ID: ${e.uuid}, 마스크: ${t.dirtyMask}`);const{rect:i,styles:r}=t,c=this.renderer.domElement.width,y=this.renderer.domElement.height;e.scale.set(i.width,i.height,1);const T=.001;this.renderOrder++,e.position.set(i.x-c/2+i.width/2,-i.y+y/2-i.height/2,r.zIndex+this.renderOrder*T);const l=e.material,u=r.backgroundColor;let w=u,M=1;if(u==="transparent"||u==="rgba(0, 0, 0, 0)")w="#ffffff",M=0;else if(u.startsWith("rgba")){const m=u.match(/[\d.]+/g);if(m&&m.length>=4){const O=m[0],C=m[1],k=m[2];M=parseFloat(m[3]),w=`rgb(${O}, ${C}, ${k})`}}const S=r.opacity*M;l.color.set(w),l.opacity=S,l.transparent=S<1,t.dirtyMask&p&&console.log(" -> 위치/크기만 업데이트됨"),t.dirtyMask&g&&console.log(" -> 스타일만 업데이트됨")}render(){this.renderer.render(this.scene,this.camera)}}function v(n,e=p|g){if(n.tagName==="SCRIPT"||n.tagName==="STYLE")return null;const t=n.getBoundingClientRect(),i={x:t.x+window.scrollX,y:t.y+window.scrollY,width:t.width,height:t.height},r=window.getComputedStyle(n),c={backgroundColor:r.backgroundColor,opacity:parseFloat(r.opacity),zIndex:parseInt(r.zIndex,10)||0},y=[];for(const T of n.children){const l=v(T);l&&y.push(l)}return{type:"BOX",element:n,rect:i,styles:c,dirtyMask:e,children:y}}class D{constructor(e,t){s(this,"target");s(this,"renderer");s(this,"observer");s(this,"isDomDirty",!1);s(this,"isRunning",!1);s(this,"pendingMask",f);s(this,"mutationTimer",null);s(this,"cssTimer",null);s(this,"onTransitionFinished",e=>{this.target.contains(e.target)&&this.mutationTimer===null&&(this.cssTimer&&clearTimeout(this.cssTimer),this.pendingMask|=p|g,this.cssTimer=window.setTimeout(()=>{this.isDomDirty=!0,this.cssTimer=null},50))});s(this,"onWindowResize",()=>{this.renderer.setSize(window.innerWidth,window.innerHeight),this.isDomDirty=!0});s(this,"renderLoop",()=>{this.isRunning&&(this.isDomDirty&&this.forceUpdateScene(),this.renderer.render(),requestAnimationFrame(this.renderLoop))});this.target=e,this.renderer=t,this.observer=new MutationObserver(i=>{let r=f;for(const c of i)c.type==="childList"?r|=b:c.type==="attributes"&&(c.attributeName==="style"||c.attributeName==="class")&&(r|=p|g);if(r!==f){if(this.pendingMask|=r,r&b){this.clearTimers(),console.log("Structural Change detected"),this.isDomDirty=!0;return}this.mutationTimer&&clearTimeout(this.mutationTimer),this.mutationTimer=window.setTimeout(()=>{this.mutationTimer=null,this.isDomDirty=!0},200)}})}start(){this.isRunning||(this.isRunning=!0,this.observer.observe(this.target,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),this.target.addEventListener("transitionend",this.onTransitionFinished),this.target.addEventListener("animationend",this.onTransitionFinished),window.addEventListener("resize",this.onWindowResize),this.forceUpdateScene(),this.renderLoop())}stop(){this.isRunning=!1,this.observer.disconnect(),this.clearTimers(),this.target.removeEventListener("transitionend",this.onTransitionFinished),this.target.removeEventListener("animationend",this.onTransitionFinished),window.removeEventListener("resize",this.onWindowResize)}clearTimers(){this.mutationTimer&&(clearTimeout(this.mutationTimer),this.mutationTimer=null),this.cssTimer&&(clearTimeout(this.cssTimer),this.cssTimer=null)}forceUpdateScene(){this.isDomDirty=!1;const e=v(this.target,this.pendingMask);e&&this.renderer.syncScene(e),this.pendingMask=f}}class R{constructor(e){s(this,"renderer");s(this,"syncer");s(this,"target");const t=document.querySelector(e);if(!t)throw new Error(`[Mirage] Element not found: ${e}`);this.target=t,this.renderer=new E,this.renderer.mount(document.body),this.syncer=new D(this.target,this.renderer)}start(){this.syncer.start()}stop(){this.syncer.stop(),this.renderer.dispose()}}o.Mirage=R,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Mirage } from './core/Mirage';
|
|
@@ -5,12 +5,13 @@ export declare class Renderer {
|
|
|
5
5
|
private readonly camera;
|
|
6
6
|
private readonly renderer;
|
|
7
7
|
private renderOrder;
|
|
8
|
+
private meshMap;
|
|
8
9
|
constructor();
|
|
9
10
|
mount(parent: HTMLElement): void;
|
|
10
11
|
dispose(): void;
|
|
11
12
|
setSize(width: number, height: number): void;
|
|
12
|
-
private clearScene;
|
|
13
|
-
private buildScene;
|
|
14
13
|
syncScene(graphNode: SceneNode): void;
|
|
14
|
+
private reconcileNode;
|
|
15
|
+
private updateMeshProperties;
|
|
15
16
|
render(): void;
|
|
16
17
|
}
|
|
@@ -11,7 +11,14 @@ export interface BoxStyles {
|
|
|
11
11
|
}
|
|
12
12
|
export interface SceneNode {
|
|
13
13
|
type: "BOX";
|
|
14
|
+
element: HTMLElement;
|
|
14
15
|
rect: NodeRect;
|
|
15
16
|
styles: BoxStyles;
|
|
17
|
+
dirtyMask: number;
|
|
16
18
|
children: SceneNode[];
|
|
17
19
|
}
|
|
20
|
+
export declare const DIRTY_NONE = 0;
|
|
21
|
+
export declare const DIRTY_RECT: number;
|
|
22
|
+
export declare const DIRTY_STYLE: number;
|
|
23
|
+
export declare const DIRTY_ZINDEX: number;
|
|
24
|
+
export declare const DIRTY_STRUCTURE: number;
|
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mirage-engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/mirage-engine.umd.js",
|
|
7
7
|
"module": "./dist/mirage-engine.js",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/dltldn333/MirageEngine"
|
|
11
|
+
},
|
|
8
12
|
"exports": {
|
|
9
13
|
".": {
|
|
10
14
|
"types": "./dist/index.d.ts",
|
package/dist/dom/Extractor.d.ts
DELETED
|
File without changes
|
|
File without changes
|