@planara/core 1.2.4 → 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 CHANGED
@@ -1,4 +1,5 @@
1
1
  ![build](https://github.com/planara/planara-core/actions/workflows/build.yml/badge.svg)
2
+ ![deploy](https://github.com/planara/planara-core/actions/workflows/deploy.yml/badge.svg)
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).
@@ -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;;;;OAIG;gBACS,MAAM,EAAE,iBAAiB;IAgBrC;;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;gBACgB,MAAM,EAAE,iBAAiB;IAgB5C;;OAEG;IACH,SAAS,CAAC,MAAM;CAIjB"}
@@ -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;;;OAGG;gBACS,MAAM,EAAE,iBAAiB;IAcrC;;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;IAerC;;OAEG;IACH,SAAS,CAAC,MAAM;CAIjB"}
@@ -5,18 +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);
19
+ protected constructor(canvas: HTMLCanvasElement);
20
20
  /**
21
21
  * Обновляет размер рендерера и камеры при изменении размеров canvas.
22
22
  */
@@ -24,14 +24,14 @@ export declare abstract class Renderer {
24
24
  /**
25
25
  * Выполняет рендеринг сцены с текущей камерой.
26
26
  */
27
- render(): void;
28
- /**
29
- * Запускает основной цикл рендеринга.
30
- */
31
- loop(): void;
27
+ protected render(): void;
32
28
  /**
33
29
  * Метод для обновления логики рендерера.
34
30
  */
35
31
  protected update(): void;
32
+ /**
33
+ * Запускает основной цикл рендеринга.
34
+ */
35
+ loop(): void;
36
36
  }
37
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;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"}
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 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;
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
@@ -19,7 +19,7 @@ class m {
19
19
  * Обновляет размер рендерера и камеры при изменении размеров canvas.
20
20
  */
21
21
  resize() {
22
- this.gl.setSize(this.canvas.clientWidth, this.canvas.clientHeight), this.camera.perspective({ aspect: this.canvas.width / this.canvas.height });
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
- loop() {
34
- this.update(), this.render(), requestAnimationFrame(this.loop.bind(this));
33
+ update() {
35
34
  }
36
35
  /**
37
- * Метод для обновления логики рендерера.
36
+ * Запускает основной цикл рендеринга.
38
37
  */
39
- update() {
38
+ loop() {
39
+ this.update(), this.render(), requestAnimationFrame(this.loop.bind(this));
40
40
  }
41
41
  }
42
42
  class I extends m {
@@ -49,8 +49,8 @@ class I extends m {
49
49
  */
50
50
  constructor(s) {
51
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
+ 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 });
54
54
  }
55
55
  /**
56
56
  * Обновление состояния рендерера.
@@ -68,6 +68,7 @@ class C extends m {
68
68
  */
69
69
  constructor(s) {
70
70
  super(s), this.orbit = new p(this.camera, {
71
+ element: this.canvas,
71
72
  target: new x(0, 0, 0),
72
73
  minPolarAngle: Math.PI / 2,
73
74
  maxPolarAngle: Math.PI / 2,
@@ -102,7 +103,7 @@ class P {
102
103
  this.type = s.type, this.position = s.position, this.normal = s.normal ?? [], this.uv = s.uv ?? [], this.material = s.material;
103
104
  }
104
105
  }
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 || {});
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 || {});
106
107
  class y {
107
108
  positions = [];
108
109
  normals = [];
@@ -115,11 +116,11 @@ class y {
115
116
  * @param objContent Строка содержимого .obj файла
116
117
  */
117
118
  parse(s) {
118
- const t = s.split(`
119
+ const e = s.split(`
119
120
  `);
120
- for (const n of t) {
121
- if (!n.trim() || n.startsWith("#")) continue;
122
- const i = n.trim().split(/\s+/);
121
+ for (const a of e) {
122
+ if (!a.trim() || a.startsWith("#")) continue;
123
+ const i = a.trim().split(/\s+/);
123
124
  switch (i[0]) {
124
125
  case "v":
125
126
  this.tmpPositions.push(i.slice(1).map(Number));
@@ -135,33 +136,33 @@ class y {
135
136
  break;
136
137
  }
137
138
  }
138
- const a = {
139
+ const r = {
139
140
  type: u.Custom,
140
141
  position: this.positions,
141
142
  ...this.normals.length > 0 && { normal: this.normals },
142
143
  ...this.uvs.length > 0 && { uv: this.uvs }
143
144
  };
144
- return new P(a);
145
+ return new P(r);
145
146
  }
146
147
  /**
147
148
  * Обрабатывает строку face (f) и разворачивает индексы в массивы для рендеринга
148
149
  */
149
150
  processFaceLine(s) {
150
- for (let t = 1; t < s.length; t++) {
151
- const a = s[t];
152
- if (!a) continue;
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
+ 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;
154
155
  if (h !== void 0) {
155
- const r = this.tmpPositions[h - 1];
156
- r && this.positions.push(...r);
156
+ const n = this.tmpPositions[h - 1];
157
+ n && this.positions.push(...n);
157
158
  }
158
159
  if (c !== void 0) {
159
- const r = this.tmpUVs[c - 1];
160
- r && this.uvs.push(...r);
160
+ const n = this.tmpUVs[c - 1];
161
+ n && this.uvs.push(...n);
161
162
  }
162
163
  if (l !== void 0) {
163
- const r = this.tmpNormals[l - 1];
164
- r && this.normals.push(...r);
164
+ const n = this.tmpNormals[l - 1];
165
+ n && this.normals.push(...n);
165
166
  }
166
167
  }
167
168
  }
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
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(`
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
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;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAmCjC;;OAEG;IACH,OAAO,CAAC,eAAe;CA2BxB"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planara/core",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"