@planara/core 1.2.3 → 1.2.5
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/README.md +2 -1
- package/dist/core/editor-renderer.d.ts +2 -1
- package/dist/core/editor-renderer.d.ts.map +1 -1
- package/dist/core/preview-renderer.d.ts +2 -1
- package/dist/core/preview-renderer.d.ts.map +1 -1
- package/dist/core/renderer.d.ts +9 -13
- package/dist/core/renderer.d.ts.map +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +42 -38
- package/dist/index.umd.js +2 -2
- package/dist/loaders/obj-loader.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|

|
|
2
|
+

|
|
2
3
|
|
|
3
4
|
## Planara Core
|
|
4
5
|
|
|
@@ -20,4 +21,4 @@
|
|
|
20
21
|
|
|
21
22
|
- Покраска объектов (через материалы или vertex colors).
|
|
22
23
|
|
|
23
|
-
- Отображение сетки и осей (Grid и Axes Helper).
|
|
24
|
+
- Отображение сетки и осей (Grid и Axes Helper).
|
|
@@ -10,8 +10,9 @@ export declare class EditorRenderer extends Renderer {
|
|
|
10
10
|
/**
|
|
11
11
|
* Инициализация сцены редактора.
|
|
12
12
|
* Создает сетку, оси координат и orbit-контроллер.
|
|
13
|
+
* @param canvas - HTMLCanvasElement для рендеринга
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
constructor(canvas: HTMLCanvasElement);
|
|
15
16
|
/**
|
|
16
17
|
* Обновление состояния рендерера.
|
|
17
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-renderer.d.ts","sourceRoot":"","sources":["../../src/core/editor-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,8CAA8C;IAC9C,OAAO,CAAC,KAAK,CAAS;IAEtB
|
|
1
|
+
{"version":3,"file":"editor-renderer.d.ts","sourceRoot":"","sources":["../../src/core/editor-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC1C,8CAA8C;IAC9C,OAAO,CAAC,KAAK,CAAS;IAEtB;;;;OAIG;gBACgB,MAAM,EAAE,iBAAiB;IAgB5C;;OAEG;IACH,SAAS,CAAC,MAAM;CAIjB"}
|
|
@@ -9,8 +9,9 @@ export declare class PreviewRenderer extends Renderer {
|
|
|
9
9
|
private orbit;
|
|
10
10
|
/**
|
|
11
11
|
* Инициализация сцены предпросмотра.
|
|
12
|
+
* @param canvas - HTMLCanvasElement для рендеринга
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
constructor(canvas: HTMLCanvasElement);
|
|
14
15
|
/**
|
|
15
16
|
* Обновление состояния рендерера.
|
|
16
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-renderer.d.ts","sourceRoot":"","sources":["../../src/core/preview-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,8CAA8C;IAC9C,OAAO,CAAC,KAAK,CAAS;IAEtB
|
|
1
|
+
{"version":3,"file":"preview-renderer.d.ts","sourceRoot":"","sources":["../../src/core/preview-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,8CAA8C;IAC9C,OAAO,CAAC,KAAK,CAAS;IAEtB;;;OAGG;gBACS,MAAM,EAAE,iBAAiB;IAerC;;OAEG;IACH,SAAS,CAAC,MAAM;CAIjB"}
|
package/dist/core/renderer.d.ts
CHANGED
|
@@ -5,22 +5,18 @@ import { Renderer as OGLRenderer, Camera, Transform } from 'ogl';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class Renderer {
|
|
7
7
|
/** Экземпляр рендерера OGL */
|
|
8
|
-
gl: OGLRenderer;
|
|
8
|
+
protected gl: OGLRenderer;
|
|
9
9
|
/** Корневой объект сцены */
|
|
10
|
-
scene: Transform;
|
|
10
|
+
protected scene: Transform;
|
|
11
11
|
/** Камера для сцены */
|
|
12
|
-
camera: Camera;
|
|
12
|
+
protected camera: Camera;
|
|
13
13
|
/** HTML-элемент canvas, на котором рендерится сцена */
|
|
14
14
|
protected canvas: HTMLCanvasElement;
|
|
15
15
|
/**
|
|
16
16
|
* Конструктор рендерера
|
|
17
17
|
* @param canvas - HTMLCanvasElement для рендеринга
|
|
18
18
|
*/
|
|
19
|
-
constructor(canvas: HTMLCanvasElement);
|
|
20
|
-
/**
|
|
21
|
-
* Метод для инициализации рендерера, добавления объектов в сцену.
|
|
22
|
-
*/
|
|
23
|
-
protected abstract init(): void;
|
|
19
|
+
protected constructor(canvas: HTMLCanvasElement);
|
|
24
20
|
/**
|
|
25
21
|
* Обновляет размер рендерера и камеры при изменении размеров canvas.
|
|
26
22
|
*/
|
|
@@ -28,14 +24,14 @@ export declare abstract class Renderer {
|
|
|
28
24
|
/**
|
|
29
25
|
* Выполняет рендеринг сцены с текущей камерой.
|
|
30
26
|
*/
|
|
31
|
-
render(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Запускает основной цикл рендеринга.
|
|
34
|
-
*/
|
|
35
|
-
loop(): void;
|
|
27
|
+
protected render(): void;
|
|
36
28
|
/**
|
|
37
29
|
* Метод для обновления логики рендерера.
|
|
38
30
|
*/
|
|
39
31
|
protected update(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Запускает основной цикл рендеринга.
|
|
34
|
+
*/
|
|
35
|
+
loop(): void;
|
|
40
36
|
}
|
|
41
37
|
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/core/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEjE;;;GAGG;AACH,8BAAsB,QAAQ;IAC5B,8BAA8B;
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/core/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEjE;;;GAGG;AACH,8BAAsB,QAAQ;IAC5B,8BAA8B;IAC9B,SAAS,CAAC,EAAE,EAAE,WAAW,CAAC;IAE1B,4BAA4B;IAC5B,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;IAE3B,uBAAuB;IACvB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAEzB,uDAAuD;IACvD,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAEpC;;;OAGG;IACH,SAAS,aAAa,MAAM,EAAE,iBAAiB;IAa/C;;OAEG;IACI,MAAM;IAUb;;OAEG;IACH,SAAS,CAAC,MAAM;IAIhB;;OAEG;IACH,SAAS,CAAC,MAAM,IAAI,IAAI;IAExB;;OAEG;IACI,IAAI;CAKZ"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("ogl");class h{gl;scene;camera;canvas;constructor(e){this.canvas=e,this.gl=new r.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new r.Transform,this.camera=new r.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0])
|
|
2
|
-
`);for(const a of
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("ogl");class h{gl;scene;camera;canvas;constructor(e){this.canvas=e,this.gl=new r.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new r.Transform,this.camera=new r.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0])}resize(){this.canvas.width=this.canvas.clientWidth,this.canvas.height=this.canvas.clientHeight,this.gl.setSize(this.canvas.clientWidth,this.canvas.clientHeight),this.camera.perspective({aspect:this.canvas.clientWidth/this.canvas.clientHeight})}render(){this.gl.render({scene:this.scene,camera:this.camera})}update(){}loop(){this.update(),this.render(),requestAnimationFrame(this.loop.bind(this))}}class u extends h{orbit;constructor(e){super(e);const s=new r.GridHelper(this.gl.gl,{size:10,divisions:10});s.position.y=-.001,s.setParent(this.scene),new r.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new r.Orbit(this.camera,{element:this.canvas})}update(){this.orbit?.update()}}class v extends h{orbit;constructor(e){super(e),this.orbit=new r.Orbit(this.camera,{element:this.canvas,target:new r.Vec3(0,0,0),minPolarAngle:Math.PI/2,maxPolarAngle:Math.PI/2,enableRotate:!0,enableZoom:!1,enablePan:!1})}update(){this.orbit?.update()}}class g{type;position;normal;uv;material;constructor(e){this.type=e.type,this.position=e.position,this.normal=e.normal??[],this.uv=e.uv??[],this.material=e.material}}var d=(t=>(t[t.Cube=0]="Cube",t[t.Sphere=1]="Sphere",t[t.Plane=2]="Plane",t[t.Cylinder=3]="Cylinder",t[t.Custom=4]="Custom",t))(d||{});class b{positions=[];normals=[];uvs=[];tmpPositions=[];tmpNormals=[];tmpUVs=[];parse(e){const s=e.split(`
|
|
2
|
+
`);for(const a of s){if(!a.trim()||a.startsWith("#"))continue;const i=a.trim().split(/\s+/);switch(i[0]){case"v":this.tmpPositions.push(i.slice(1).map(Number));break;case"vn":this.tmpNormals.push(i.slice(1).map(Number));break;case"vt":this.tmpUVs.push(i.slice(1).map(Number));break;case"f":this.processFaceLine(i);break}}const o={type:d.Custom,position:this.positions,...this.normals.length>0&&{normal:this.normals},...this.uvs.length>0&&{uv:this.uvs}};return new g(o)}processFaceLine(e){for(let s=1;s<e.length;s++){const o=e[s];if(!o)continue;const[a,i,c]=o.split("/"),l=a?parseInt(a,10):void 0,p=i?parseInt(i,10):void 0,m=c?parseInt(c,10):void 0;if(l!==void 0){const n=this.tmpPositions[l-1];n&&this.positions.push(...n)}if(p!==void 0){const n=this.tmpUVs[p-1];n&&this.uvs.push(...n)}if(m!==void 0){const n=this.tmpNormals[m-1];n&&this.normals.push(...n)}}}}exports.EditorRenderer=u;exports.ObjLoader=b;exports.PreviewRenderer=v;exports.Renderer=h;
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Renderer as
|
|
1
|
+
import { Renderer as d, Transform as v, Camera as g, GridHelper as b, AxesHelper as f, Orbit as p, Vec3 as x } from "ogl";
|
|
2
2
|
class m {
|
|
3
3
|
/** Экземпляр рендерера OGL */
|
|
4
4
|
gl;
|
|
@@ -13,13 +13,13 @@ class m {
|
|
|
13
13
|
* @param canvas - HTMLCanvasElement для рендеринга
|
|
14
14
|
*/
|
|
15
15
|
constructor(s) {
|
|
16
|
-
this.canvas = s, this.gl = new
|
|
16
|
+
this.canvas = s, this.gl = new d({ canvas: s }), this.gl.setSize(s.clientWidth, s.clientHeight), this.gl.gl.clearColor(1, 1, 1, 1), this.scene = new v(), this.camera = new g(this.gl.gl, { fov: 45 }), this.camera.position.set(1, 1, 7), this.camera.lookAt([0, 0, 0]);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Обновляет размер рендерера и камеры при изменении размеров canvas.
|
|
20
20
|
*/
|
|
21
21
|
resize() {
|
|
22
|
-
this.gl.setSize(this.canvas.clientWidth, this.canvas.clientHeight), this.camera.perspective({ aspect: this.canvas.
|
|
22
|
+
this.canvas.width = this.canvas.clientWidth, this.canvas.height = this.canvas.clientHeight, this.gl.setSize(this.canvas.clientWidth, this.canvas.clientHeight), this.camera.perspective({ aspect: this.canvas.clientWidth / this.canvas.clientHeight });
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Выполняет рендеринг сцены с текущей камерой.
|
|
@@ -28,15 +28,15 @@ class m {
|
|
|
28
28
|
this.gl.render({ scene: this.scene, camera: this.camera });
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
*
|
|
31
|
+
* Метод для обновления логики рендерера.
|
|
32
32
|
*/
|
|
33
|
-
|
|
34
|
-
this.update(), this.render(), requestAnimationFrame(this.loop.bind(this));
|
|
33
|
+
update() {
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
|
-
*
|
|
36
|
+
* Запускает основной цикл рендеринга.
|
|
38
37
|
*/
|
|
39
|
-
|
|
38
|
+
loop() {
|
|
39
|
+
this.update(), this.render(), requestAnimationFrame(this.loop.bind(this));
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
class I extends m {
|
|
@@ -45,10 +45,12 @@ class I extends m {
|
|
|
45
45
|
/**
|
|
46
46
|
* Инициализация сцены редактора.
|
|
47
47
|
* Создает сетку, оси координат и orbit-контроллер.
|
|
48
|
+
* @param canvas - HTMLCanvasElement для рендеринга
|
|
48
49
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
constructor(s) {
|
|
51
|
+
super(s);
|
|
52
|
+
const e = new b(this.gl.gl, { size: 10, divisions: 10 });
|
|
53
|
+
e.position.y = -1e-3, e.setParent(this.scene), new f(this.gl.gl, { size: 6, symmetric: !0 }).setParent(this.scene), this.orbit = new p(this.camera, { element: this.canvas });
|
|
52
54
|
}
|
|
53
55
|
/**
|
|
54
56
|
* Обновление состояния рендерера.
|
|
@@ -62,9 +64,11 @@ class C extends m {
|
|
|
62
64
|
orbit;
|
|
63
65
|
/**
|
|
64
66
|
* Инициализация сцены предпросмотра.
|
|
67
|
+
* @param canvas - HTMLCanvasElement для рендеринга
|
|
65
68
|
*/
|
|
66
|
-
|
|
67
|
-
this.orbit = new p(this.camera, {
|
|
69
|
+
constructor(s) {
|
|
70
|
+
super(s), this.orbit = new p(this.camera, {
|
|
71
|
+
element: this.canvas,
|
|
68
72
|
target: new x(0, 0, 0),
|
|
69
73
|
minPolarAngle: Math.PI / 2,
|
|
70
74
|
maxPolarAngle: Math.PI / 2,
|
|
@@ -99,7 +103,7 @@ class P {
|
|
|
99
103
|
this.type = s.type, this.position = s.position, this.normal = s.normal ?? [], this.uv = s.uv ?? [], this.material = s.material;
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
|
-
var
|
|
106
|
+
var u = /* @__PURE__ */ ((t) => (t[t.Cube = 0] = "Cube", t[t.Sphere = 1] = "Sphere", t[t.Plane = 2] = "Plane", t[t.Cylinder = 3] = "Cylinder", t[t.Custom = 4] = "Custom", t))(u || {});
|
|
103
107
|
class y {
|
|
104
108
|
positions = [];
|
|
105
109
|
normals = [];
|
|
@@ -112,53 +116,53 @@ class y {
|
|
|
112
116
|
* @param objContent Строка содержимого .obj файла
|
|
113
117
|
*/
|
|
114
118
|
parse(s) {
|
|
115
|
-
const
|
|
119
|
+
const e = s.split(`
|
|
116
120
|
`);
|
|
117
|
-
for (const
|
|
118
|
-
if (!
|
|
119
|
-
const
|
|
120
|
-
switch (
|
|
121
|
+
for (const a of e) {
|
|
122
|
+
if (!a.trim() || a.startsWith("#")) continue;
|
|
123
|
+
const i = a.trim().split(/\s+/);
|
|
124
|
+
switch (i[0]) {
|
|
121
125
|
case "v":
|
|
122
|
-
this.tmpPositions.push(
|
|
126
|
+
this.tmpPositions.push(i.slice(1).map(Number));
|
|
123
127
|
break;
|
|
124
128
|
case "vn":
|
|
125
|
-
this.tmpNormals.push(
|
|
129
|
+
this.tmpNormals.push(i.slice(1).map(Number));
|
|
126
130
|
break;
|
|
127
131
|
case "vt":
|
|
128
|
-
this.tmpUVs.push(
|
|
132
|
+
this.tmpUVs.push(i.slice(1).map(Number));
|
|
129
133
|
break;
|
|
130
134
|
case "f":
|
|
131
|
-
this.processFaceLine(
|
|
135
|
+
this.processFaceLine(i);
|
|
132
136
|
break;
|
|
133
137
|
}
|
|
134
138
|
}
|
|
135
|
-
const
|
|
136
|
-
type:
|
|
139
|
+
const r = {
|
|
140
|
+
type: u.Custom,
|
|
137
141
|
position: this.positions,
|
|
138
142
|
...this.normals.length > 0 && { normal: this.normals },
|
|
139
143
|
...this.uvs.length > 0 && { uv: this.uvs }
|
|
140
144
|
};
|
|
141
|
-
return new P(
|
|
145
|
+
return new P(r);
|
|
142
146
|
}
|
|
143
147
|
/**
|
|
144
148
|
* Обрабатывает строку face (f) и разворачивает индексы в массивы для рендеринга
|
|
145
149
|
*/
|
|
146
150
|
processFaceLine(s) {
|
|
147
|
-
for (let
|
|
148
|
-
const
|
|
149
|
-
if (!
|
|
150
|
-
const [
|
|
151
|
+
for (let e = 1; e < s.length; e++) {
|
|
152
|
+
const r = s[e];
|
|
153
|
+
if (!r) continue;
|
|
154
|
+
const [a, i, o] = r.split("/"), h = a ? parseInt(a, 10) : void 0, c = i ? parseInt(i, 10) : void 0, l = o ? parseInt(o, 10) : void 0;
|
|
151
155
|
if (h !== void 0) {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
if (l !== void 0) {
|
|
156
|
-
const i = this.tmpUVs[l - 1];
|
|
157
|
-
i && this.uvs.push(...i);
|
|
156
|
+
const n = this.tmpPositions[h - 1];
|
|
157
|
+
n && this.positions.push(...n);
|
|
158
158
|
}
|
|
159
159
|
if (c !== void 0) {
|
|
160
|
-
const
|
|
161
|
-
|
|
160
|
+
const n = this.tmpUVs[c - 1];
|
|
161
|
+
n && this.uvs.push(...n);
|
|
162
|
+
}
|
|
163
|
+
if (l !== void 0) {
|
|
164
|
+
const n = this.tmpNormals[l - 1];
|
|
165
|
+
n && this.normals.push(...n);
|
|
162
166
|
}
|
|
163
167
|
}
|
|
164
168
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("ogl")):typeof define=="function"&&define.amd?define(["exports","ogl"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i.PlanaraCore={},i.OGL))})(this,(function(i,s){"use strict";class c{gl;scene;camera;canvas;constructor(e){this.canvas=e,this.gl=new s.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new s.Transform,this.camera=new s.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0])
|
|
2
|
-
`);for(const o of
|
|
1
|
+
(function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("ogl")):typeof define=="function"&&define.amd?define(["exports","ogl"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i.PlanaraCore={},i.OGL))})(this,(function(i,s){"use strict";class c{gl;scene;camera;canvas;constructor(e){this.canvas=e,this.gl=new s.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new s.Transform,this.camera=new s.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0])}resize(){this.canvas.width=this.canvas.clientWidth,this.canvas.height=this.canvas.clientHeight,this.gl.setSize(this.canvas.clientWidth,this.canvas.clientHeight),this.camera.perspective({aspect:this.canvas.clientWidth/this.canvas.clientHeight})}render(){this.gl.render({scene:this.scene,camera:this.camera})}update(){}loop(){this.update(),this.render(),requestAnimationFrame(this.loop.bind(this))}}class v extends c{orbit;constructor(e){super(e);const n=new s.GridHelper(this.gl.gl,{size:10,divisions:10});n.position.y=-.001,n.setParent(this.scene),new s.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new s.Orbit(this.camera,{element:this.canvas})}update(){this.orbit?.update()}}class f extends c{orbit;constructor(e){super(e),this.orbit=new s.Orbit(this.camera,{element:this.canvas,target:new s.Vec3(0,0,0),minPolarAngle:Math.PI/2,maxPolarAngle:Math.PI/2,enableRotate:!0,enableZoom:!1,enablePan:!1})}update(){this.orbit?.update()}}class b{type;position;normal;uv;material;constructor(e){this.type=e.type,this.position=e.position,this.normal=e.normal??[],this.uv=e.uv??[],this.material=e.material}}var l=(t=>(t[t.Cube=0]="Cube",t[t.Sphere=1]="Sphere",t[t.Plane=2]="Plane",t[t.Cylinder=3]="Cylinder",t[t.Custom=4]="Custom",t))(l||{});class g{positions=[];normals=[];uvs=[];tmpPositions=[];tmpNormals=[];tmpUVs=[];parse(e){const n=e.split(`
|
|
2
|
+
`);for(const o of n){if(!o.trim()||o.startsWith("#"))continue;const r=o.trim().split(/\s+/);switch(r[0]){case"v":this.tmpPositions.push(r.slice(1).map(Number));break;case"vn":this.tmpNormals.push(r.slice(1).map(Number));break;case"vt":this.tmpUVs.push(r.slice(1).map(Number));break;case"f":this.processFaceLine(r);break}}const h={type:l.Custom,position:this.positions,...this.normals.length>0&&{normal:this.normals},...this.uvs.length>0&&{uv:this.uvs}};return new b(h)}processFaceLine(e){for(let n=1;n<e.length;n++){const h=e[n];if(!h)continue;const[o,r,p]=h.split("/"),m=o?parseInt(o,10):void 0,d=r?parseInt(r,10):void 0,u=p?parseInt(p,10):void 0;if(m!==void 0){const a=this.tmpPositions[m-1];a&&this.positions.push(...a)}if(d!==void 0){const a=this.tmpUVs[d-1];a&&this.uvs.push(...a)}if(u!==void 0){const a=this.tmpNormals[u-1];a&&this.normals.push(...a)}}}}i.EditorRenderer=v,i.ObjLoader=g,i.PreviewRenderer=f,i.Renderer=c,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"obj-loader.d.ts","sourceRoot":"","sources":["../../src/loaders/obj-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA+B,MAAM,gBAAgB,CAAC;AAErE,qBAAa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,GAAG,CAAgB;IAE3B,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,MAAM,CAAkB;IAEhC;;;OAGG;
|
|
1
|
+
{"version":3,"file":"obj-loader.d.ts","sourceRoot":"","sources":["../../src/loaders/obj-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA+B,MAAM,gBAAgB,CAAC;AAErE,qBAAa,SAAS;IACpB,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,GAAG,CAAgB;IAE3B,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,MAAM,CAAkB;IAEhC;;;OAGG;IACI,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAmCxC;;OAEG;IACH,OAAO,CAAC,eAAe;CA2BxB"}
|