@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 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).
@@ -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;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
- 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;IAerC;;OAEG;IACH,SAAS,CAAC,MAAM;CAIjB"}
@@ -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;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;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]),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 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 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,13 +13,13 @@ 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.
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 {
@@ -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 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
- init() {
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 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 || {});
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 n = s.split(`
119
+ const e = s.split(`
116
120
  `);
117
- for (const r of n) {
118
- if (!r.trim() || r.startsWith("#")) continue;
119
- const e = r.trim().split(/\s+/);
120
- switch (e[0]) {
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(e.slice(1).map(Number));
126
+ this.tmpPositions.push(i.slice(1).map(Number));
123
127
  break;
124
128
  case "vn":
125
- this.tmpNormals.push(e.slice(1).map(Number));
129
+ this.tmpNormals.push(i.slice(1).map(Number));
126
130
  break;
127
131
  case "vt":
128
- this.tmpUVs.push(e.slice(1).map(Number));
132
+ this.tmpUVs.push(i.slice(1).map(Number));
129
133
  break;
130
134
  case "f":
131
- this.processFaceLine(e);
135
+ this.processFaceLine(i);
132
136
  break;
133
137
  }
134
138
  }
135
- const a = {
136
- type: d.Custom,
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(a);
145
+ return new P(r);
142
146
  }
143
147
  /**
144
148
  * Обрабатывает строку face (f) и разворачивает индексы в массивы для рендеринга
145
149
  */
146
150
  processFaceLine(s) {
147
- for (let n = 1; n < s.length; n++) {
148
- const a = s[n];
149
- 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;
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 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);
156
+ const n = this.tmpPositions[h - 1];
157
+ n && this.positions.push(...n);
158
158
  }
159
159
  if (c !== void 0) {
160
- const i = this.tmpNormals[c - 1];
161
- i && this.normals.push(...i);
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]),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,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;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.3",
3
+ "version": "1.2.5",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"