@threepipe/plugin-svg-renderer 0.1.0 → 0.2.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.
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @license
3
- * @threepipe/plugin-svg-renderer v0.1.0
3
+ * @threepipe/plugin-svg-renderer v0.2.1
4
4
  * Copyright 2022-2024 repalash <palash@shaders.app>
5
5
  * GPLV3 License
6
6
  * See ./dependencies.txt for any bundled third-party dependencies and licenses.
7
7
  */
8
- import { Vector3, Color as Color$1, Vector2, Vector4, Box3, Matrix4, Frustum, Matrix3, DoubleSide, Box2, SRGBColorSpace, Camera, uiToggle as uiToggle$1, uiConfig as uiConfig$1, uiButton, uiFolderContainer as uiFolderContainer$1, AViewerPluginSync, computeMorphedAttributes, Triangle, BufferAttribute, Plane, Line3 as Line3$1, Sphere, BackSide, FrontSide, Mesh, Ray, onChange as onChange$1, uiVector, timeout } from "threepipe";
8
+ import { Vector3, Color as Color$1, Vector2, Vector4, Box3, Matrix4, Frustum, Matrix3, DoubleSide, Box2, Camera, uiToggle as uiToggle$1, uiConfig as uiConfig$1, uiButton, uiFolderContainer as uiFolderContainer$1, AViewerPluginSync, computeMorphedAttributes, Triangle, BufferAttribute, Plane, Line3 as Line3$1, Sphere, BackSide, FrontSide, Mesh, Ray, onChange as onChange$1, uiVector, timeout } from "threepipe";
9
9
  import { Vector3 as Vector3$1, Matrix4 as Matrix4$1, Vector2 as Vector2$1, Color as Color$2, Raycaster, DoubleSide as DoubleSide$1, Line3, PerspectiveCamera, Box2 as Box2$1, Triangle as Triangle$1, Mesh as Mesh$1 } from "threepipe";
10
10
  class RenderableObject {
11
11
  constructor() {
@@ -502,7 +502,6 @@ let SVGRenderer$1 = class SVGRenderer {
502
502
  this.sortObjects = true;
503
503
  this.sortElements = true;
504
504
  this.overdraw = 0.5;
505
- this.outputColorSpace = SRGBColorSpace;
506
505
  this.info = {
507
506
  render: {
508
507
  vertices: 0,
@@ -555,7 +554,7 @@ let SVGRenderer$1 = class SVGRenderer {
555
554
  }
556
555
  this.clear = function() {
557
556
  removeChildNodes();
558
- _svg.style.backgroundColor = _clearColor.getStyle(_this.outputColorSpace);
557
+ _svg.style.backgroundColor = _clearColor.getStyle();
559
558
  };
560
559
  this.render = function(scene, camera) {
561
560
  if (camera instanceof Camera === false) {
@@ -565,7 +564,7 @@ let SVGRenderer$1 = class SVGRenderer {
565
564
  const background = scene.background;
566
565
  if (background && background.isColor) {
567
566
  removeChildNodes();
568
- _svg.style.backgroundColor = background.getStyle(_this.outputColorSpace);
567
+ _svg.style.backgroundColor = background.getStyle();
569
568
  } else if (this.autoClear === true) {
570
569
  this.clear();
571
570
  }
@@ -675,7 +674,7 @@ let SVGRenderer$1 = class SVGRenderer {
675
674
  const light = lights[l];
676
675
  const lightColor = light.color;
677
676
  if (light.isDirectionalLight) {
678
- const lightPosition = _vector3.setFromMatrixPosition(light.matrixWorld).normalize();
677
+ const lightPosition = _vector3.setFromMatrixPosition(light.matrixWorld).sub(_normal2.setFromMatrixPosition(light.target.matrixWorld)).normalize();
679
678
  let amount = normal.dot(lightPosition);
680
679
  if (amount <= 0)
681
680
  continue;
@@ -708,14 +707,14 @@ let SVGRenderer$1 = class SVGRenderer {
708
707
  const path = "M" + convert(v1.x - scaleX * 0.5) + "," + convert(v1.y - scaleY * 0.5) + "h" + convert(scaleX) + "v" + convert(scaleY) + "h" + convert(-scaleX) + "z";
709
708
  let style = "";
710
709
  if (material.isSpriteMaterial || material.isPointsMaterial) {
711
- style = "fill:" + material.color.getStyle(_this.outputColorSpace) + ";fill-opacity:" + material.opacity;
710
+ style = "fill:" + material.color.getStyle() + ";fill-opacity:" + material.opacity;
712
711
  }
713
712
  addPath(style, path);
714
713
  }
715
714
  function renderLine(v1, v2, material) {
716
715
  const path = "M" + convert(v1.positionScreen.x) + "," + convert(v1.positionScreen.y) + "L" + convert(v2.positionScreen.x) + "," + convert(v2.positionScreen.y);
717
716
  if (material.isLineBasicMaterial) {
718
- let style = "fill:none;stroke:" + material.color.getStyle(_this.outputColorSpace) + ";stroke-opacity:" + material.opacity + ";stroke-width:" + material.linewidth + ";stroke-linecap:" + material.linecap;
717
+ let style = "fill:none;stroke:" + material.color.getStyle() + ";stroke-opacity:" + material.opacity + ";stroke-width:" + material.linewidth + ";stroke-linecap:" + material.linecap;
719
718
  if (material.isLineDashedMaterial) {
720
719
  style = style + ";stroke-dasharray:" + material.dashSize + "," + material.gapSize;
721
720
  }
@@ -746,9 +745,9 @@ let SVGRenderer$1 = class SVGRenderer {
746
745
  _color2.setRGB(_normal2.x, _normal2.y, _normal2.z).multiplyScalar(0.5).addScalar(0.5);
747
746
  }
748
747
  if (material.wireframe) {
749
- style = "fill:none;stroke:" + _color2.getStyle(_this.outputColorSpace) + ";stroke-opacity:" + material.opacity + ";stroke-width:" + material.wireframeLinewidth + ";stroke-linecap:" + material.wireframeLinecap + ";stroke-linejoin:" + material.wireframeLinejoin;
748
+ style = "fill:none;stroke:" + _color2.getStyle() + ";stroke-opacity:" + material.opacity + ";stroke-width:" + material.wireframeLinewidth + ";stroke-linecap:" + material.wireframeLinecap + ";stroke-linejoin:" + material.wireframeLinejoin;
750
749
  } else {
751
- style = "fill:" + _color2.getStyle(_this.outputColorSpace) + ";fill-opacity:" + material.opacity;
750
+ style = "fill:" + _color2.getStyle() + ";fill-opacity:" + material.opacity;
752
751
  }
753
752
  addPath(style, path);
754
753
  }