@planara/core 1.3.0 → 1.3.1

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.
@@ -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,IAAI,EAAE,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAE/F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;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,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,SAAS,aAAa,MAAM,EAAE,iBAAiB;IAyB/C;;OAEG;IACI,MAAM;IAUb;;OAEG;IACH,SAAS,CAAC,MAAM;IAIhB;;OAEG;IACH,SAAS,CAAC,MAAM,IAAI,IAAI;IAExB;;OAEG;IACI,IAAI;IAMX;;;OAGG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM;CAkBhC"}
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,IAAI,EAAE,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAC;AAE/F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;;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,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;IAE3B;;;OAGG;IACH,SAAS,aAAa,MAAM,EAAE,iBAAiB;IAyB/C;;OAEG;IACI,MAAM;IAMb;;OAEG;IACH,SAAS,CAAC,MAAM;IAIhB;;OAEG;IACH,SAAS,CAAC,MAAM,IAAI,IAAI;IAExB;;OAEG;IACI,IAAI;IAMX;;;OAGG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM;CAkBhC"}
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("ogl");function p(t){const e=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("ogl");function v(t){const e=`
2
2
  attribute vec3 position;
3
3
  attribute vec3 normal;
4
4
  attribute vec2 uv;
@@ -15,7 +15,7 @@
15
15
  vNormal = normalize(normalMatrix * normal);
16
16
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
17
17
  }
18
- `,i=`
18
+ `,s=`
19
19
  precision highp float;
20
20
 
21
21
  uniform sampler2D tMap;
@@ -29,5 +29,5 @@
29
29
  gl_FragColor.rgb = tex + shading;
30
30
  gl_FragColor.a = 1.0;
31
31
  }
32
- `,r=new s.Texture(t);return new s.Program(t,{vertex:e,fragment:i,uniforms:{tMap:{value:r}}})}class l{gl;scene;camera;canvas;program;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.program=p(this.gl.gl)}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))}addFigure(e){const i=new s.Geometry(this.gl.gl,{position:{size:3,data:new Float32Array(e.position)},normal:{size:3,data:new Float32Array(e.normal??[])},uv:{size:2,data:new Float32Array(e.uv??[])}}),r=new s.Mesh(this.gl.gl,{geometry:i,program:this.program});return r.setParent(this.scene),r}}class d extends l{orbit;constructor(e){super(e);const i=new s.GridHelper(this.gl.gl,{size:10,divisions:10});i.position.y=-.001,i.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 g extends l{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 u=(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||{});class f{positions=[];normals=[];uvs=[];tmpPositions=[];tmpNormals=[];tmpUVs=[];load(e){const i=e.split(`
33
- `);for(const o of i){if(!o.trim()||o.startsWith("#"))continue;const a=o.trim().split(/\s+/);switch(a[0]){case"v":this.tmpPositions.push(a.slice(1).map(Number));break;case"vn":this.tmpNormals.push(a.slice(1).map(Number));break;case"vt":this.tmpUVs.push(a.slice(1).map(Number));break;case"f":this.processFaceLine(a);break}}const r={type:u.Custom,position:this.positions,...this.normals.length>0&&{normal:this.normals},...this.uvs.length>0&&{uv:this.uvs}};return new b(r)}processFaceLine(e){for(let i=1;i<e.length;i++){const r=e[i];if(!r)continue;const[o,a,c]=r.split("/"),h=o?parseInt(o,10):void 0,m=a?parseInt(a,10):void 0,v=c?parseInt(c,10):void 0;if(h!==void 0){const n=this.tmpPositions[h-1];n&&this.positions.push(...n)}if(m!==void 0){const n=this.tmpUVs[m-1];n&&this.uvs.push(...n)}if(v!==void 0){const n=this.tmpNormals[v-1];n&&this.normals.push(...n)}}}}exports.EditorRenderer=d;exports.ObjLoader=f;exports.PreviewRenderer=g;exports.Renderer=l;exports.createProgram=p;
32
+ `,r=new i.Texture(t);return new i.Program(t,{vertex:e,fragment:s,uniforms:{tMap:{value:r}}})}class l{gl;scene;camera;canvas;program;constructor(e){this.canvas=e,this.gl=new i.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new i.Transform,this.camera=new i.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0]),this.program=v(this.gl.gl)}resize(){this.gl.setSize(this.canvas.width,this.canvas.height),this.camera.perspective({aspect:this.canvas.width/this.canvas.height})}render(){this.gl.render({scene:this.scene,camera:this.camera})}update(){}loop(){this.update(),this.render(),requestAnimationFrame(this.loop.bind(this))}addFigure(e){const s=new i.Geometry(this.gl.gl,{position:{size:3,data:new Float32Array(e.position)},normal:{size:3,data:new Float32Array(e.normal??[])},uv:{size:2,data:new Float32Array(e.uv??[])}}),r=new i.Mesh(this.gl.gl,{geometry:s,program:this.program});return r.setParent(this.scene),r}}class d extends l{orbit;constructor(e){super(e);const s=new i.GridHelper(this.gl.gl,{size:10,divisions:10});s.position.y=-.001,s.setParent(this.scene),new i.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new i.Orbit(this.camera,{element:this.canvas})}update(){this.orbit?.update()}}class g extends l{orbit;constructor(e){super(e),this.orbit=new i.Orbit(this.camera,{element:this.canvas,target:new i.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 u=(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||{});class f{positions=[];normals=[];uvs=[];tmpPositions=[];tmpNormals=[];tmpUVs=[];load(e){const s=e.split(`
33
+ `);for(const o of s){if(!o.trim()||o.startsWith("#"))continue;const a=o.trim().split(/\s+/);switch(a[0]){case"v":this.tmpPositions.push(a.slice(1).map(Number));break;case"vn":this.tmpNormals.push(a.slice(1).map(Number));break;case"vt":this.tmpUVs.push(a.slice(1).map(Number));break;case"f":this.processFaceLine(a);break}}const r={type:u.Custom,position:this.positions,...this.normals.length>0&&{normal:this.normals},...this.uvs.length>0&&{uv:this.uvs}};return new b(r)}processFaceLine(e){for(let s=1;s<e.length;s++){const r=e[s];if(!r)continue;const[o,a,c]=r.split("/"),m=o?parseInt(o,10):void 0,h=a?parseInt(a,10):void 0,p=c?parseInt(c,10):void 0;if(m!==void 0){const n=this.tmpPositions[m-1];n&&this.positions.push(...n)}if(h!==void 0){const n=this.tmpUVs[h-1];n&&this.uvs.push(...n)}if(p!==void 0){const n=this.tmpNormals[p-1];n&&this.normals.push(...n)}}}}exports.EditorRenderer=d;exports.ObjLoader=f;exports.PreviewRenderer=g;exports.Renderer=l;exports.createProgram=v;
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Texture as u, Program as d, Renderer as g, Transform as b, Camera as f, Geometry as x, Mesh as w, GridHelper as y, AxesHelper as P, Orbit as m, Vec3 as M } from "ogl";
1
+ import { Texture as u, Program as d, Renderer as g, Transform as b, Camera as f, Geometry as x, Mesh as w, GridHelper as y, AxesHelper as P, Orbit as c, Vec3 as M } from "ogl";
2
2
  function z(e) {
3
3
  const t = (
4
4
  /* glsl */
@@ -20,7 +20,7 @@ function z(e) {
20
20
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
21
21
  }
22
22
  `
23
- ), i = (
23
+ ), s = (
24
24
  /* glsl */
25
25
  `
26
26
  precision highp float;
@@ -37,11 +37,11 @@ function z(e) {
37
37
  gl_FragColor.a = 1.0;
38
38
  }
39
39
  `
40
- ), s = new u(e);
40
+ ), i = new u(e);
41
41
  return new d(e, {
42
42
  vertex: t,
43
- fragment: i,
44
- uniforms: { tMap: { value: s } }
43
+ fragment: s,
44
+ uniforms: { tMap: { value: i } }
45
45
  });
46
46
  }
47
47
  class p {
@@ -65,7 +65,7 @@ class p {
65
65
  * Обновляет размер рендерера и камеры при изменении размеров canvas.
66
66
  */
67
67
  resize() {
68
- 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 });
68
+ this.gl.setSize(this.canvas.width, this.canvas.height), this.camera.perspective({ aspect: this.canvas.width / this.canvas.height });
69
69
  }
70
70
  /**
71
71
  * Выполняет рендеринг сцены с текущей камерой.
@@ -89,15 +89,15 @@ class p {
89
89
  * @param figure Данные фигуры: position, normal, uv
90
90
  */
91
91
  addFigure(t) {
92
- const i = new x(this.gl.gl, {
92
+ const s = new x(this.gl.gl, {
93
93
  position: { size: 3, data: new Float32Array(t.position) },
94
94
  normal: { size: 3, data: new Float32Array(t.normal ?? []) },
95
95
  uv: { size: 2, data: new Float32Array(t.uv ?? []) }
96
- }), s = new w(this.gl.gl, {
97
- geometry: i,
96
+ }), i = new w(this.gl.gl, {
97
+ geometry: s,
98
98
  program: this.program
99
99
  });
100
- return s.setParent(this.scene), s;
100
+ return i.setParent(this.scene), i;
101
101
  }
102
102
  }
103
103
  class N extends p {
@@ -110,8 +110,8 @@ class N extends p {
110
110
  */
111
111
  constructor(t) {
112
112
  super(t);
113
- const i = new y(this.gl.gl, { size: 10, divisions: 10 });
114
- i.position.y = -1e-3, i.setParent(this.scene), new P(this.gl.gl, { size: 6, symmetric: !0 }).setParent(this.scene), this.orbit = new m(this.camera, { element: this.canvas });
113
+ const s = new y(this.gl.gl, { size: 10, divisions: 10 });
114
+ s.position.y = -1e-3, s.setParent(this.scene), new P(this.gl.gl, { size: 6, symmetric: !0 }).setParent(this.scene), this.orbit = new c(this.camera, { element: this.canvas });
115
115
  }
116
116
  /**
117
117
  * Обновление состояния рендерера.
@@ -128,7 +128,7 @@ class F extends p {
128
128
  * @param canvas - HTMLCanvasElement для рендеринга
129
129
  */
130
130
  constructor(t) {
131
- super(t), this.orbit = new m(this.camera, {
131
+ super(t), this.orbit = new c(this.camera, {
132
132
  element: this.canvas,
133
133
  target: new M(0, 0, 0),
134
134
  minPolarAngle: Math.PI / 2,
@@ -181,9 +181,9 @@ class A {
181
181
  * @param objContent Строка содержимого .obj файла
182
182
  */
183
183
  load(t) {
184
- const i = t.split(`
184
+ const s = t.split(`
185
185
  `);
186
- for (const n of i) {
186
+ for (const n of s) {
187
187
  if (!n.trim() || n.startsWith("#")) continue;
188
188
  const r = n.trim().split(/\s+/);
189
189
  switch (r[0]) {
@@ -201,28 +201,28 @@ class A {
201
201
  break;
202
202
  }
203
203
  }
204
- const s = {
204
+ const i = {
205
205
  type: v.Custom,
206
206
  position: this.positions,
207
207
  ...this.normals.length > 0 && { normal: this.normals },
208
208
  ...this.uvs.length > 0 && { uv: this.uvs }
209
209
  };
210
- return new C(s);
210
+ return new C(i);
211
211
  }
212
212
  /**
213
213
  * Обрабатывает строку face (f) и разворачивает индексы в массивы для рендеринга
214
214
  */
215
215
  processFaceLine(t) {
216
- for (let i = 1; i < t.length; i++) {
217
- const s = t[i];
218
- if (!s) continue;
219
- const [n, r, o] = s.split("/"), l = n ? parseInt(n, 10) : void 0, c = r ? parseInt(r, 10) : void 0, h = o ? parseInt(o, 10) : void 0;
216
+ for (let s = 1; s < t.length; s++) {
217
+ const i = t[s];
218
+ if (!i) continue;
219
+ const [n, r, o] = i.split("/"), l = n ? parseInt(n, 10) : void 0, m = r ? parseInt(r, 10) : void 0, h = o ? parseInt(o, 10) : void 0;
220
220
  if (l !== void 0) {
221
221
  const a = this.tmpPositions[l - 1];
222
222
  a && this.positions.push(...a);
223
223
  }
224
- if (c !== void 0) {
225
- const a = this.tmpUVs[c - 1];
224
+ if (m !== void 0) {
225
+ const a = this.tmpUVs[m - 1];
226
226
  a && this.uvs.push(...a);
227
227
  }
228
228
  if (h !== void 0) {
package/dist/index.umd.js CHANGED
@@ -29,5 +29,5 @@
29
29
  gl_FragColor.rgb = tex + shading;
30
30
  gl_FragColor.a = 1.0;
31
31
  }
32
- `,n=new i.Texture(t);return new i.Program(t,{vertex:e,fragment:s,uniforms:{tMap:{value:n}}})}class l{gl;scene;camera;canvas;program;constructor(e){this.canvas=e,this.gl=new i.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new i.Transform,this.camera=new i.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0]),this.program=h(this.gl.gl)}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))}addFigure(e){const s=new i.Geometry(this.gl.gl,{position:{size:3,data:new Float32Array(e.position)},normal:{size:3,data:new Float32Array(e.normal??[])},uv:{size:2,data:new Float32Array(e.uv??[])}}),n=new i.Mesh(this.gl.gl,{geometry:s,program:this.program});return n.setParent(this.scene),n}}class g extends l{orbit;constructor(e){super(e);const s=new i.GridHelper(this.gl.gl,{size:10,divisions:10});s.position.y=-.001,s.setParent(this.scene),new i.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new i.Orbit(this.camera,{element:this.canvas})}update(){this.orbit?.update()}}class f extends l{orbit;constructor(e){super(e),this.orbit=new i.Orbit(this.camera,{element:this.canvas,target:new i.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 m=(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))(m||{});class w{positions=[];normals=[];uvs=[];tmpPositions=[];tmpNormals=[];tmpUVs=[];load(e){const s=e.split(`
33
- `);for(const c of s){if(!c.trim()||c.startsWith("#"))continue;const a=c.trim().split(/\s+/);switch(a[0]){case"v":this.tmpPositions.push(a.slice(1).map(Number));break;case"vn":this.tmpNormals.push(a.slice(1).map(Number));break;case"vt":this.tmpUVs.push(a.slice(1).map(Number));break;case"f":this.processFaceLine(a);break}}const n={type:m.Custom,position:this.positions,...this.normals.length>0&&{normal:this.normals},...this.uvs.length>0&&{uv:this.uvs}};return new b(n)}processFaceLine(e){for(let s=1;s<e.length;s++){const n=e[s];if(!n)continue;const[c,a,p]=n.split("/"),v=c?parseInt(c,10):void 0,u=a?parseInt(a,10):void 0,d=p?parseInt(p,10):void 0;if(v!==void 0){const o=this.tmpPositions[v-1];o&&this.positions.push(...o)}if(u!==void 0){const o=this.tmpUVs[u-1];o&&this.uvs.push(...o)}if(d!==void 0){const o=this.tmpNormals[d-1];o&&this.normals.push(...o)}}}}r.EditorRenderer=g,r.ObjLoader=w,r.PreviewRenderer=f,r.Renderer=l,r.createProgram=h,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
32
+ `,n=new i.Texture(t);return new i.Program(t,{vertex:e,fragment:s,uniforms:{tMap:{value:n}}})}class c{gl;scene;camera;canvas;program;constructor(e){this.canvas=e,this.gl=new i.Renderer({canvas:e}),this.gl.setSize(e.clientWidth,e.clientHeight),this.gl.gl.clearColor(1,1,1,1),this.scene=new i.Transform,this.camera=new i.Camera(this.gl.gl,{fov:45}),this.camera.position.set(1,1,7),this.camera.lookAt([0,0,0]),this.program=h(this.gl.gl)}resize(){this.gl.setSize(this.canvas.width,this.canvas.height),this.camera.perspective({aspect:this.canvas.width/this.canvas.height})}render(){this.gl.render({scene:this.scene,camera:this.camera})}update(){}loop(){this.update(),this.render(),requestAnimationFrame(this.loop.bind(this))}addFigure(e){const s=new i.Geometry(this.gl.gl,{position:{size:3,data:new Float32Array(e.position)},normal:{size:3,data:new Float32Array(e.normal??[])},uv:{size:2,data:new Float32Array(e.uv??[])}}),n=new i.Mesh(this.gl.gl,{geometry:s,program:this.program});return n.setParent(this.scene),n}}class g extends c{orbit;constructor(e){super(e);const s=new i.GridHelper(this.gl.gl,{size:10,divisions:10});s.position.y=-.001,s.setParent(this.scene),new i.AxesHelper(this.gl.gl,{size:6,symmetric:!0}).setParent(this.scene),this.orbit=new i.Orbit(this.camera,{element:this.canvas})}update(){this.orbit?.update()}}class f extends c{orbit;constructor(e){super(e),this.orbit=new i.Orbit(this.camera,{element:this.canvas,target:new i.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 m=(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))(m||{});class w{positions=[];normals=[];uvs=[];tmpPositions=[];tmpNormals=[];tmpUVs=[];load(e){const s=e.split(`
33
+ `);for(const l of s){if(!l.trim()||l.startsWith("#"))continue;const a=l.trim().split(/\s+/);switch(a[0]){case"v":this.tmpPositions.push(a.slice(1).map(Number));break;case"vn":this.tmpNormals.push(a.slice(1).map(Number));break;case"vt":this.tmpUVs.push(a.slice(1).map(Number));break;case"f":this.processFaceLine(a);break}}const n={type:m.Custom,position:this.positions,...this.normals.length>0&&{normal:this.normals},...this.uvs.length>0&&{uv:this.uvs}};return new b(n)}processFaceLine(e){for(let s=1;s<e.length;s++){const n=e[s];if(!n)continue;const[l,a,p]=n.split("/"),v=l?parseInt(l,10):void 0,u=a?parseInt(a,10):void 0,d=p?parseInt(p,10):void 0;if(v!==void 0){const o=this.tmpPositions[v-1];o&&this.positions.push(...o)}if(u!==void 0){const o=this.tmpUVs[u-1];o&&this.uvs.push(...o)}if(d!==void 0){const o=this.tmpNormals[d-1];o&&this.normals.push(...o)}}}}r.EditorRenderer=g,r.ObjLoader=w,r.PreviewRenderer=f,r.Renderer=c,r.createProgram=h,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planara/core",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"