@planara/core 1.2.3 → 1.2.4

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.
@@ -10,8 +10,9 @@ export declare class EditorRenderer extends Renderer {
10
10
  /**
11
11
  * Инициализация сцены редактора.
12
12
  * Создает сетку, оси координат и orbit-контроллер.
13
+ * @param canvas - HTMLCanvasElement для рендеринга
13
14
  */
14
- protected init(): void;
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;;;OAGG;IACH,SAAS,CAAC,IAAI;IAcd;;OAEG;IACH,SAAS,CAAC,MAAM;CAIjB"}
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;gBACS,MAAM,EAAE,iBAAiB;IAgBrC;;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
- protected init(): void;
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;;OAEG;IACH,SAAS,CAAC,IAAI;IAYd;;OAEG;IACH,SAAS,CAAC,MAAM;CAIjB"}
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;IAcrC;;OAEG;IACH,SAAS,CAAC,MAAM;CAIjB"}
@@ -17,10 +17,6 @@ export declare abstract class Renderer {
17
17
  * @param canvas - HTMLCanvasElement для рендеринга
18
18
  */
19
19
  constructor(canvas: HTMLCanvasElement);
20
- /**
21
- * Метод для инициализации рендерера, добавления объектов в сцену.
22
- */
23
- protected abstract init(): void;
24
20
  /**
25
21
  * Обновляет размер рендерера и камеры при изменении размеров canvas.
26
22
  */
@@ -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;IACvB,EAAE,EAAE,WAAW,CAAC;IAEvB,4BAA4B;IACrB,KAAK,EAAE,SAAS,CAAC;IAExB,uBAAuB;IAChB,MAAM,EAAE,MAAM,CAAC;IAEtB,uDAAuD;IACvD,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAEpC;;;OAGG;gBACS,MAAM,EAAE,iBAAiB;IAerC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,IAAI,IAAI;IAE/B;;OAEG;IACH,MAAM;IAKN;;OAEG;IACH,MAAM;IAIN;;OAEG;IACH,IAAI;IAMJ;;OAEG;IACH,SAAS,CAAC,MAAM,IAAI,IAAI;CACzB"}
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;IACvB,EAAE,EAAE,WAAW,CAAC;IAEvB,4BAA4B;IACrB,KAAK,EAAE,SAAS,CAAC;IAExB,uBAAuB;IAChB,MAAM,EAAE,MAAM,CAAC;IAEtB,uDAAuD;IACvD,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAEpC;;;OAGG;gBACS,MAAM,EAAE,iBAAiB;IAarC;;OAEG;IACH,MAAM;IAKN;;OAEG;IACH,MAAM;IAIN;;OAEG;IACH,IAAI;IAMJ;;OAEG;IACH,SAAS,CAAC,MAAM,IAAI,IAAI;CACzB"}
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]),this.init()}resize(){this.gl.setSize(this.canvas.clientWidth,this.canvas.clientHeight),this.camera.perspective({aspect:this.canvas.width/this.canvas.height})}render(){this.gl.render({scene:this.scene,camera:this.camera})}loop(){this.update(),this.render(),requestAnimationFrame(this.loop.bind(this))}update(){}}class u extends h{orbit;init(){const e=new r.GridHelper(this.gl.gl,{size:10,divisions:10});e.position.y=-.001,e.setParent(this.scene),new r.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new r.Orbit(this.camera)}update(){this.orbit?.update()}}class v extends h{orbit;init(){this.orbit=new r.Orbit(this.camera,{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=(s=>(s[s.Cube=0]="Cube",s[s.Sphere=1]="Sphere",s[s.Plane=2]="Plane",s[s.Cylinder=3]="Cylinder",s[s.Custom=4]="Custom",s))(d||{});class b{positions=[];normals=[];uvs=[];tmpPositions=[];tmpNormals=[];tmpUVs=[];parse(e){const n=e.split(`
2
- `);for(const a of n){if(!a.trim()||a.startsWith("#"))continue;const t=a.trim().split(/\s+/);switch(t[0]){case"v":this.tmpPositions.push(t.slice(1).map(Number));break;case"vn":this.tmpNormals.push(t.slice(1).map(Number));break;case"vt":this.tmpUVs.push(t.slice(1).map(Number));break;case"f":this.processFaceLine(t);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 n=1;n<e.length;n++){const o=e[n];if(!o)continue;const[a,t,l]=o.split("/"),c=a?parseInt(a,10):void 0,p=t?parseInt(t,10):void 0,m=l?parseInt(l,10):void 0;if(c!==void 0){const i=this.tmpPositions[c-1];i&&this.positions.push(...i)}if(p!==void 0){const i=this.tmpUVs[p-1];i&&this.uvs.push(...i)}if(m!==void 0){const i=this.tmpNormals[m-1];i&&this.normals.push(...i)}}}}exports.EditorRenderer=u;exports.ObjLoader=b;exports.PreviewRenderer=v;exports.Renderer=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("ogl");class h{gl;scene;camera;canvas;constructor(e){this.canvas=e,this.gl=new n.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new n.Transform,this.camera=new n.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0])}resize(){this.gl.setSize(this.canvas.clientWidth,this.canvas.clientHeight),this.camera.perspective({aspect:this.canvas.width/this.canvas.height})}render(){this.gl.render({scene:this.scene,camera:this.camera})}loop(){this.update(),this.render(),requestAnimationFrame(this.loop.bind(this))}update(){}}class d extends h{orbit;constructor(e){super(e);const t=new n.GridHelper(this.gl.gl,{size:10,divisions:10});t.position.y=-.001,t.setParent(this.scene),new n.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new n.Orbit(this.camera)}update(){this.orbit?.update()}}class v extends h{orbit;constructor(e){super(e),this.orbit=new n.Orbit(this.camera,{target:new n.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 u=(s=>(s[s.Cube=0]="Cube",s[s.Sphere=1]="Sphere",s[s.Plane=2]="Plane",s[s.Cylinder=3]="Cylinder",s[s.Custom=4]="Custom",s))(u||{});class b{positions=[];normals=[];uvs=[];tmpPositions=[];tmpNormals=[];tmpUVs=[];parse(e){const t=e.split(`
2
+ `);for(const a of t){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:u.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 t=1;t<e.length;t++){const o=e[t];if(!o)continue;const[a,i,l]=o.split("/"),c=a?parseInt(a,10):void 0,p=i?parseInt(i,10):void 0,m=l?parseInt(l,10):void 0;if(c!==void 0){const r=this.tmpPositions[c-1];r&&this.positions.push(...r)}if(p!==void 0){const r=this.tmpUVs[p-1];r&&this.uvs.push(...r)}if(m!==void 0){const r=this.tmpNormals[m-1];r&&this.normals.push(...r)}}}}exports.EditorRenderer=d;exports.ObjLoader=b;exports.PreviewRenderer=v;exports.Renderer=h;
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Renderer as u, Transform as v, Camera as g, GridHelper as b, AxesHelper as f, Orbit as p, Vec3 as x } from "ogl";
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,7 +13,7 @@ class m {
13
13
  * @param canvas - HTMLCanvasElement для рендеринга
14
14
  */
15
15
  constructor(s) {
16
- this.canvas = s, this.gl = new u({ 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]), this.init();
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.
@@ -45,10 +45,12 @@ class I extends m {
45
45
  /**
46
46
  * Инициализация сцены редактора.
47
47
  * Создает сетку, оси координат и orbit-контроллер.
48
+ * @param canvas - HTMLCanvasElement для рендеринга
48
49
  */
49
- init() {
50
- const s = new b(this.gl.gl, { size: 10, divisions: 10 });
51
- s.position.y = -1e-3, s.setParent(this.scene), new f(this.gl.gl, { size: 6, symmetric: !0 }).setParent(this.scene), this.orbit = new p(this.camera);
50
+ constructor(s) {
51
+ super(s);
52
+ const t = new b(this.gl.gl, { size: 10, divisions: 10 });
53
+ t.position.y = -1e-3, t.setParent(this.scene), new f(this.gl.gl, { size: 6, symmetric: !0 }).setParent(this.scene), this.orbit = new p(this.camera);
52
54
  }
53
55
  /**
54
56
  * Обновление состояния рендерера.
@@ -62,9 +64,10 @@ class C extends m {
62
64
  orbit;
63
65
  /**
64
66
  * Инициализация сцены предпросмотра.
67
+ * @param canvas - HTMLCanvasElement для рендеринга
65
68
  */
66
- init() {
67
- this.orbit = new p(this.camera, {
69
+ constructor(s) {
70
+ super(s), this.orbit = new p(this.camera, {
68
71
  target: new x(0, 0, 0),
69
72
  minPolarAngle: Math.PI / 2,
70
73
  maxPolarAngle: Math.PI / 2,
@@ -99,7 +102,7 @@ class P {
99
102
  this.type = s.type, this.position = s.position, this.normal = s.normal ?? [], this.uv = s.uv ?? [], this.material = s.material;
100
103
  }
101
104
  }
102
- var d = /* @__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))(d || {});
105
+ var u = /* @__PURE__ */ ((e) => (e[e.Cube = 0] = "Cube", e[e.Sphere = 1] = "Sphere", e[e.Plane = 2] = "Plane", e[e.Cylinder = 3] = "Cylinder", e[e.Custom = 4] = "Custom", e))(u || {});
103
106
  class y {
104
107
  positions = [];
105
108
  normals = [];
@@ -112,28 +115,28 @@ class y {
112
115
  * @param objContent Строка содержимого .obj файла
113
116
  */
114
117
  parse(s) {
115
- const n = s.split(`
118
+ const t = s.split(`
116
119
  `);
117
- for (const r of n) {
118
- if (!r.trim() || r.startsWith("#")) continue;
119
- const e = r.trim().split(/\s+/);
120
- switch (e[0]) {
120
+ for (const n of t) {
121
+ if (!n.trim() || n.startsWith("#")) continue;
122
+ const i = n.trim().split(/\s+/);
123
+ switch (i[0]) {
121
124
  case "v":
122
- this.tmpPositions.push(e.slice(1).map(Number));
125
+ this.tmpPositions.push(i.slice(1).map(Number));
123
126
  break;
124
127
  case "vn":
125
- this.tmpNormals.push(e.slice(1).map(Number));
128
+ this.tmpNormals.push(i.slice(1).map(Number));
126
129
  break;
127
130
  case "vt":
128
- this.tmpUVs.push(e.slice(1).map(Number));
131
+ this.tmpUVs.push(i.slice(1).map(Number));
129
132
  break;
130
133
  case "f":
131
- this.processFaceLine(e);
134
+ this.processFaceLine(i);
132
135
  break;
133
136
  }
134
137
  }
135
138
  const a = {
136
- type: d.Custom,
139
+ type: u.Custom,
137
140
  position: this.positions,
138
141
  ...this.normals.length > 0 && { normal: this.normals },
139
142
  ...this.uvs.length > 0 && { uv: this.uvs }
@@ -144,21 +147,21 @@ class y {
144
147
  * Обрабатывает строку face (f) и разворачивает индексы в массивы для рендеринга
145
148
  */
146
149
  processFaceLine(s) {
147
- for (let n = 1; n < s.length; n++) {
148
- const a = s[n];
150
+ for (let t = 1; t < s.length; t++) {
151
+ const a = s[t];
149
152
  if (!a) continue;
150
- const [r, e, o] = a.split("/"), h = r ? parseInt(r, 10) : void 0, l = e ? parseInt(e, 10) : void 0, c = o ? parseInt(o, 10) : void 0;
153
+ const [n, i, o] = a.split("/"), h = n ? parseInt(n, 10) : void 0, c = i ? parseInt(i, 10) : void 0, l = o ? parseInt(o, 10) : void 0;
151
154
  if (h !== void 0) {
152
- const i = this.tmpPositions[h - 1];
153
- i && this.positions.push(...i);
154
- }
155
- if (l !== void 0) {
156
- const i = this.tmpUVs[l - 1];
157
- i && this.uvs.push(...i);
155
+ const r = this.tmpPositions[h - 1];
156
+ r && this.positions.push(...r);
158
157
  }
159
158
  if (c !== void 0) {
160
- const i = this.tmpNormals[c - 1];
161
- i && this.normals.push(...i);
159
+ const r = this.tmpUVs[c - 1];
160
+ r && this.uvs.push(...r);
161
+ }
162
+ if (l !== void 0) {
163
+ const r = this.tmpNormals[l - 1];
164
+ r && this.normals.push(...r);
162
165
  }
163
166
  }
164
167
  }
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]),this.init()}resize(){this.gl.setSize(this.canvas.clientWidth,this.canvas.clientHeight),this.camera.perspective({aspect:this.canvas.width/this.canvas.height})}render(){this.gl.render({scene:this.scene,camera:this.camera})}loop(){this.update(),this.render(),requestAnimationFrame(this.loop.bind(this))}update(){}}class v extends c{orbit;init(){const e=new s.GridHelper(this.gl.gl,{size:10,divisions:10});e.position.y=-.001,e.setParent(this.scene),new s.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new s.Orbit(this.camera)}update(){this.orbit?.update()}}class f extends c{orbit;init(){this.orbit=new s.Orbit(this.camera,{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 a=e.split(`
2
- `);for(const o of a){if(!o.trim()||o.startsWith("#"))continue;const n=o.trim().split(/\s+/);switch(n[0]){case"v":this.tmpPositions.push(n.slice(1).map(Number));break;case"vn":this.tmpNormals.push(n.slice(1).map(Number));break;case"vt":this.tmpUVs.push(n.slice(1).map(Number));break;case"f":this.processFaceLine(n);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 a=1;a<e.length;a++){const h=e[a];if(!h)continue;const[o,n,p]=h.split("/"),m=o?parseInt(o,10):void 0,d=n?parseInt(n,10):void 0,u=p?parseInt(p,10):void 0;if(m!==void 0){const r=this.tmpPositions[m-1];r&&this.positions.push(...r)}if(d!==void 0){const r=this.tmpUVs[d-1];r&&this.uvs.push(...r)}if(u!==void 0){const r=this.tmpNormals[u-1];r&&this.normals.push(...r)}}}}i.EditorRenderer=v,i.ObjLoader=g,i.PreviewRenderer=f,i.Renderer=c,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(i,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("ogl")):typeof define=="function"&&define.amd?define(["exports","ogl"],t):(i=typeof globalThis<"u"?globalThis:i||self,t(i.PlanaraCore={},i.OGL))})(this,(function(i,t){"use strict";class c{gl;scene;camera;canvas;constructor(e){this.canvas=e,this.gl=new t.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new t.Transform,this.camera=new t.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0])}resize(){this.gl.setSize(this.canvas.clientWidth,this.canvas.clientHeight),this.camera.perspective({aspect:this.canvas.width/this.canvas.height})}render(){this.gl.render({scene:this.scene,camera:this.camera})}loop(){this.update(),this.render(),requestAnimationFrame(this.loop.bind(this))}update(){}}class v extends c{orbit;constructor(e){super(e);const n=new t.GridHelper(this.gl.gl,{size:10,divisions:10});n.position.y=-.001,n.setParent(this.scene),new t.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new t.Orbit(this.camera)}update(){this.orbit?.update()}}class f extends c{orbit;constructor(e){super(e),this.orbit=new t.Orbit(this.camera,{target:new t.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=(s=>(s[s.Cube=0]="Cube",s[s.Sphere=1]="Sphere",s[s.Plane=2]="Plane",s[s.Cylinder=3]="Cylinder",s[s.Custom=4]="Custom",s))(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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planara/core",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"