From a1d1b2aa9fc0b6abc55ad7894312f1100f6b466e Mon Sep 17 00:00:00 2001 From: ShuangLiu Date: Tue, 23 Jul 2024 18:18:21 +0800 Subject: [PATCH] feat(graphic): move graphic3D to @orillusion/graphic (#427) --- .../compute/graphic3d}/Graphic3DShader.ts | 0 .../compute/graphic3d}/GraphicDecCompute.ts | 0 .../graphic3d}/GraphicDynamicCompute.ts | 0 .../compute/graphic3d}/GraphicFaceComput2.ts | 0 .../compute/graphic3d}/GraphicFaceCompute.ts | 0 .../compute/graphic3d}/GraphicFaceCompute3.ts | 0 .../compute/graphic3d}/GraphicLineCompute.ts | 0 .../compute/graphic3d}/GraphicTrailCompute.ts | 0 .../graphic3d}/GraphicTrailCompute2.ts | 0 packages/graphic/index.ts | 17 +- packages/graphic/package.json | 4 +- .../renderer}/Graphic3DBatchRenderer.ts | 12 +- .../renderer}/Graphic3DFillRenderer.ts | 2 +- .../renderer}/Graphic3DFixedRenderMaterial.ts | 5 +- .../renderer}/Graphic3DLineBatchRenderer.ts | 2 +- .../graphic/renderer}/Graphic3DRender.ts | 12 +- .../graphic/renderer}/Graphics3DShape.ts | 4 +- packages/graphic/renderer/GrassRenderer.ts | 5 +- packages/graphic/renderer/Shape3DMaker.ts | 3 +- packages/graphic/renderer/Shape3DRenderer.ts | 5 +- .../renderer/graphic3d}/DynamicDrawStruct.ts | 2 +- .../graphic3d}/DynamicFaceRenderer.ts | 0 .../renderer/graphic3d}/Float32ArrayUtil.ts | 2 +- .../graphic3d}/Graphic3DFaceRenderer.ts | 21 +-- .../renderer/graphic3d}/Graphic3DMesh.ts | 6 +- .../graphic3d}/Graphic3DMeshRenderer.ts | 14 +- .../graphic3d}/Graphic3DRibbonRenderer.ts | 21 +-- .../graphic/renderer/graphic3d}/ShapeInfo.ts | 4 +- .../graphic/renderer/shape3d/LineShape3D.ts | 2 +- .../graphic/renderer/shape3d/Path3DShape3D.ts | 3 +- packages/graphic/renderer/shape3d/Shape3D.ts | 3 +- packages/graphic/tsconfig.json | 3 +- .../animation/Sample_CameraPathAnimation.ts | 18 +- samples/base/Sample_BoundingBox.ts | 9 +- samples/base/Sample_ComponentLife.ts | 2 - samples/graphic/Sample_GraphicGrass.ts | 47 +---- samples/graphic/Sample_GraphicLine.ts | 22 ++- samples/graphic/Sample_GraphicMeshWave.ts | 18 +- samples/graphic/Sample_GraphicMesh_0.ts | 110 +---------- samples/graphic/Sample_GraphicMesh_1.ts | 104 +---------- samples/graphic/Sample_GraphicMesh_2.ts | 101 +--------- samples/graphic/Sample_GraphicMesh_3.ts | 48 +---- samples/graphic/Sample_GraphicMesh_4.ts | 28 +-- samples/graphic/Sample_GraphicMesh_5.ts | 96 +--------- samples/graphic/Sample_GraphicMesh_6.ts | 50 ++--- samples/graphic/Sample_GraphicMesh_7.ts | 37 ++-- samples/graphic/Sample_GraphicMesh_Color.ts | 173 ------------------ .../graphic/Sample_GraphicMesh_SpriteSheet.ts | 42 +---- samples/graphic/Sample_Shape3D.ts | 8 +- samples/graphic/Sample_Shape3DPath2D.ts | 6 +- samples/graphic/Sample_Shape3DPath3D.ts | 5 +- samples/graphic/_Sample_GraphicShape.ts | 155 ---------------- samples/graphic/_Sample_GraphicTrailing.ts | 15 +- samples/graphic/_Sample_GraphicTrailing2.ts | 16 +- samples/graphic/_Sample_GraphicTrailing3.ts | 15 +- samples/lights/Sample_CSM.ts | 7 +- samples/octree/Sample_OctTreeBox.ts | 11 +- samples/octree/Sample_OctTreeFrustum.ts | 13 +- samples/octree/Sample_OctTreeRay.ts | 12 +- samples/utils/GUIShape3D.ts | 2 +- src/components/lights/Light.ts | 5 +- src/components/lights/PointLight.ts | 5 +- src/components/lights/SpotLight.ts | 5 +- src/components/renderer/MeshRenderer.ts | 5 +- src/core/View3D.ts | 14 -- src/gfx/renderJob/collect/EntityCollect.ts | 8 +- .../passRenderer/state/RendererMask.ts | 1 + src/index.ts | 23 --- src/loader/parser/prefab/prefabData/APatch.ts | 26 +-- 69 files changed, 272 insertions(+), 1142 deletions(-) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/Graphic3DShader.ts (100%) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/GraphicDecCompute.ts (100%) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/GraphicDynamicCompute.ts (100%) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/GraphicFaceComput2.ts (100%) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/GraphicFaceCompute.ts (100%) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/GraphicFaceCompute3.ts (100%) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/GraphicLineCompute.ts (100%) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/GraphicTrailCompute.ts (100%) rename {src/assets/shader/graphic => packages/graphic/compute/graphic3d}/GraphicTrailCompute2.ts (100%) rename {src/gfx/renderJob/passRenderer/graphic => packages/graphic/renderer}/Graphic3DBatchRenderer.ts (90%) rename {src/gfx/renderJob/passRenderer/graphic => packages/graphic/renderer}/Graphic3DFillRenderer.ts (75%) rename {src/gfx/renderJob/passRenderer/graphic => packages/graphic/renderer}/Graphic3DFixedRenderMaterial.ts (77%) rename {src/gfx/renderJob/passRenderer/graphic => packages/graphic/renderer}/Graphic3DLineBatchRenderer.ts (75%) rename {src/gfx/renderJob/passRenderer/graphic => packages/graphic/renderer}/Graphic3DRender.ts (97%) rename {src/gfx/renderJob/passRenderer/graphic => packages/graphic/renderer}/Graphics3DShape.ts (97%) rename {src/gfx/renderJob/passRenderer/graphic/new => packages/graphic/renderer/graphic3d}/DynamicDrawStruct.ts (54%) rename {src/gfx/renderJob/passRenderer/graphic/new => packages/graphic/renderer/graphic3d}/DynamicFaceRenderer.ts (100%) rename {src/gfx/renderJob/passRenderer/graphic/new => packages/graphic/renderer/graphic3d}/Float32ArrayUtil.ts (86%) rename {src/gfx/renderJob/passRenderer/graphic/new => packages/graphic/renderer/graphic3d}/Graphic3DFaceRenderer.ts (85%) rename {src/gfx/renderJob/passRenderer/graphic/new => packages/graphic/renderer/graphic3d}/Graphic3DMesh.ts (90%) rename {src/gfx/renderJob/passRenderer/graphic/new => packages/graphic/renderer/graphic3d}/Graphic3DMeshRenderer.ts (76%) rename {src/gfx/renderJob/passRenderer/graphic/new => packages/graphic/renderer/graphic3d}/Graphic3DRibbonRenderer.ts (81%) rename {src/gfx/renderJob/passRenderer/graphic/new => packages/graphic/renderer/graphic3d}/ShapeInfo.ts (73%) delete mode 100644 samples/graphic/Sample_GraphicMesh_Color.ts delete mode 100644 samples/graphic/_Sample_GraphicShape.ts diff --git a/src/assets/shader/graphic/Graphic3DShader.ts b/packages/graphic/compute/graphic3d/Graphic3DShader.ts similarity index 100% rename from src/assets/shader/graphic/Graphic3DShader.ts rename to packages/graphic/compute/graphic3d/Graphic3DShader.ts diff --git a/src/assets/shader/graphic/GraphicDecCompute.ts b/packages/graphic/compute/graphic3d/GraphicDecCompute.ts similarity index 100% rename from src/assets/shader/graphic/GraphicDecCompute.ts rename to packages/graphic/compute/graphic3d/GraphicDecCompute.ts diff --git a/src/assets/shader/graphic/GraphicDynamicCompute.ts b/packages/graphic/compute/graphic3d/GraphicDynamicCompute.ts similarity index 100% rename from src/assets/shader/graphic/GraphicDynamicCompute.ts rename to packages/graphic/compute/graphic3d/GraphicDynamicCompute.ts diff --git a/src/assets/shader/graphic/GraphicFaceComput2.ts b/packages/graphic/compute/graphic3d/GraphicFaceComput2.ts similarity index 100% rename from src/assets/shader/graphic/GraphicFaceComput2.ts rename to packages/graphic/compute/graphic3d/GraphicFaceComput2.ts diff --git a/src/assets/shader/graphic/GraphicFaceCompute.ts b/packages/graphic/compute/graphic3d/GraphicFaceCompute.ts similarity index 100% rename from src/assets/shader/graphic/GraphicFaceCompute.ts rename to packages/graphic/compute/graphic3d/GraphicFaceCompute.ts diff --git a/src/assets/shader/graphic/GraphicFaceCompute3.ts b/packages/graphic/compute/graphic3d/GraphicFaceCompute3.ts similarity index 100% rename from src/assets/shader/graphic/GraphicFaceCompute3.ts rename to packages/graphic/compute/graphic3d/GraphicFaceCompute3.ts diff --git a/src/assets/shader/graphic/GraphicLineCompute.ts b/packages/graphic/compute/graphic3d/GraphicLineCompute.ts similarity index 100% rename from src/assets/shader/graphic/GraphicLineCompute.ts rename to packages/graphic/compute/graphic3d/GraphicLineCompute.ts diff --git a/src/assets/shader/graphic/GraphicTrailCompute.ts b/packages/graphic/compute/graphic3d/GraphicTrailCompute.ts similarity index 100% rename from src/assets/shader/graphic/GraphicTrailCompute.ts rename to packages/graphic/compute/graphic3d/GraphicTrailCompute.ts diff --git a/src/assets/shader/graphic/GraphicTrailCompute2.ts b/packages/graphic/compute/graphic3d/GraphicTrailCompute2.ts similarity index 100% rename from src/assets/shader/graphic/GraphicTrailCompute2.ts rename to packages/graphic/compute/graphic3d/GraphicTrailCompute2.ts diff --git a/packages/graphic/index.ts b/packages/graphic/index.ts index 689d3212..f5d81db2 100644 --- a/packages/graphic/index.ts +++ b/packages/graphic/index.ts @@ -1,5 +1,3 @@ -export * from "./compute/grass/GrassAnimCompute_cs" -export * from "./compute/grass/GrassGeometryCompute_cs" export * from "./renderer/GrassRenderer" export * from "./renderer/Shape3DRenderer" export * from "./renderer/Shape3DMaker" @@ -12,3 +10,18 @@ export * from "./renderer/shape3d/LineShape3D" export * from "./renderer/shape3d/Shape3D" export * from "./renderer/shape3d/Path3DShape3D" export * from "./renderer/shape3d/Path2DShape3D" + +export * from "./renderer/Graphics3DShape" +export * from "./renderer/Graphic3DRender" +export * from "./renderer/Graphic3DBatchRenderer" +export * from "./renderer/Graphic3DLineBatchRenderer" +export * from "./renderer/Graphic3DFixedRenderMaterial" +export * from "./renderer/Graphic3DFillRenderer" +export * from "./renderer/graphic3d/DynamicDrawStruct" +export * from "./renderer/graphic3d/DynamicFaceRenderer" +export * from "./renderer/graphic3d/Float32ArrayUtil" +export * from "./renderer/graphic3d/Graphic3DFaceRenderer" +export * from "./renderer/graphic3d/Graphic3DMesh" +export * from "./renderer/graphic3d/Graphic3DMeshRenderer" +export * from "./renderer/graphic3d/Graphic3DRibbonRenderer" +export * from "./renderer/graphic3d/ShapeInfo" \ No newline at end of file diff --git a/packages/graphic/package.json b/packages/graphic/package.json index fe5bd929..d6c5e73e 100644 --- a/packages/graphic/package.json +++ b/packages/graphic/package.json @@ -1,6 +1,6 @@ { "name": "@orillusion/graphic", - "version": "0.1.1", + "version": "0.2.0", "author": "Orillusion", "description": "Orillusion graphic Plugin", "main": "./dist/graphic.umd.js", @@ -22,7 +22,7 @@ "url": "git+https://github.com/Orillusion/orillusion.git" }, "dependencies": { - "@orillusion/core": "^0.7.0", + "@orillusion/core": "^0.8.0", "earcut": "^2.2.4" } } diff --git a/src/gfx/renderJob/passRenderer/graphic/Graphic3DBatchRenderer.ts b/packages/graphic/renderer/Graphic3DBatchRenderer.ts similarity index 90% rename from src/gfx/renderJob/passRenderer/graphic/Graphic3DBatchRenderer.ts rename to packages/graphic/renderer/Graphic3DBatchRenderer.ts index 5fbc857b..7c71a5ff 100644 --- a/src/gfx/renderJob/passRenderer/graphic/Graphic3DBatchRenderer.ts +++ b/packages/graphic/renderer/Graphic3DBatchRenderer.ts @@ -1,12 +1,7 @@ -import { RenderNode } from "../../../../components/renderer/RenderNode"; -import { View3D } from "../../../../core/View3D"; -import { Color } from "../../../../math/Color"; -import { Vector3 } from "../../../../math/Vector3"; -import { RendererPassState } from "../state/RendererPassState"; -import { PassType } from "../state/PassType"; + +import { ClusterLightingBuffer, Color, GeometryBase, PassType, RendererMask, RendererPassState, RenderNode, Vector3, VertexAttributeName, View3D } from "@orillusion/core"; import { Graphics3DShape } from "./Graphics3DShape"; -import { ClusterLightingBuffer } from "../cluster/ClusterLightingBuffer"; -import { GeometryBase, Graphic3DFixedRenderMaterial, VertexAttributeName } from "../../../.."; +import { Graphic3DFixedRenderMaterial } from "./Graphic3DFixedRenderMaterial"; /** * @internal @@ -29,6 +24,7 @@ export class Graphic3DBatchRenderer extends RenderNode { public init() { super.init(); + this.addRendererMask(RendererMask.Graphic3D); this.castGI = false; this.castShadow = false; this.geometry = new GeometryBase(); diff --git a/src/gfx/renderJob/passRenderer/graphic/Graphic3DFillRenderer.ts b/packages/graphic/renderer/Graphic3DFillRenderer.ts similarity index 75% rename from src/gfx/renderJob/passRenderer/graphic/Graphic3DFillRenderer.ts rename to packages/graphic/renderer/Graphic3DFillRenderer.ts index 854ca759..d6a39a7c 100644 --- a/src/gfx/renderJob/passRenderer/graphic/Graphic3DFillRenderer.ts +++ b/packages/graphic/renderer/Graphic3DFillRenderer.ts @@ -1,4 +1,4 @@ -import { GPUPrimitiveTopology } from "../../../graphics/webGpu/WebGPUConst"; +import { GPUPrimitiveTopology } from "@orillusion/core"; import { Graphic3DBatchRenderer } from "./Graphic3DBatchRenderer"; /** diff --git a/src/gfx/renderJob/passRenderer/graphic/Graphic3DFixedRenderMaterial.ts b/packages/graphic/renderer/Graphic3DFixedRenderMaterial.ts similarity index 77% rename from src/gfx/renderJob/passRenderer/graphic/Graphic3DFixedRenderMaterial.ts rename to packages/graphic/renderer/Graphic3DFixedRenderMaterial.ts index 5eb07ba5..e3c423cd 100644 --- a/src/gfx/renderJob/passRenderer/graphic/Graphic3DFixedRenderMaterial.ts +++ b/packages/graphic/renderer/Graphic3DFixedRenderMaterial.ts @@ -1,6 +1,5 @@ -import { Engine3D, GPUPrimitiveTopology, RenderShaderPass, Shader, ShaderLib, Texture } from "../../../.."; -import { Graphic3DShader } from "../../../../assets/shader/graphic/Graphic3DShader"; -import { Material } from "../../../../materials/Material"; +import { GPUPrimitiveTopology, RenderShaderPass, Shader, ShaderLib, Material } from "@orillusion/core"; +import { Graphic3DShader } from "../compute/graphic3d/Graphic3DShader"; /** * @internal diff --git a/src/gfx/renderJob/passRenderer/graphic/Graphic3DLineBatchRenderer.ts b/packages/graphic/renderer/Graphic3DLineBatchRenderer.ts similarity index 75% rename from src/gfx/renderJob/passRenderer/graphic/Graphic3DLineBatchRenderer.ts rename to packages/graphic/renderer/Graphic3DLineBatchRenderer.ts index fed71b5f..c4c78ded 100644 --- a/src/gfx/renderJob/passRenderer/graphic/Graphic3DLineBatchRenderer.ts +++ b/packages/graphic/renderer/Graphic3DLineBatchRenderer.ts @@ -1,4 +1,4 @@ -import { GPUPrimitiveTopology } from "../../../graphics/webGpu/WebGPUConst"; +import { GPUPrimitiveTopology } from "@orillusion/core"; import { Graphic3DBatchRenderer } from "./Graphic3DBatchRenderer"; /** diff --git a/src/gfx/renderJob/passRenderer/graphic/Graphic3DRender.ts b/packages/graphic/renderer/Graphic3DRender.ts similarity index 97% rename from src/gfx/renderJob/passRenderer/graphic/Graphic3DRender.ts rename to packages/graphic/renderer/Graphic3DRender.ts index edf7597c..cd56700d 100644 --- a/src/gfx/renderJob/passRenderer/graphic/Graphic3DRender.ts +++ b/packages/graphic/renderer/Graphic3DRender.ts @@ -1,16 +1,7 @@ -import { GeometryBase } from "../../../../core/geometry/GeometryBase"; -import { Color } from "../../../../math/Color"; -import { Vector3 } from "../../../../math/Vector3"; -import { DEGREES_TO_RADIANS } from "../../../../math/MathUtil"; -import { Transform } from "../../../../components/Transform"; -import { BoundingBox } from "../../../../core/bound/BoundingBox"; -import { Camera3D } from "../../../../core/Camera3D"; -import { CameraType } from "../../../../core/CameraType"; -import { Object3D } from "../../../../core/entities/Object3D"; +import { BoundingBox, BoundUtil, Camera3D, CameraType, Color, DEGREES_TO_RADIANS, GeometryBase, Object3D, Transform, Vector3 } from "@orillusion/core"; import { Graphics3DShape } from "./Graphics3DShape"; import { Graphic3DFillRenderer } from "./Graphic3DFillRenderer"; import { Graphic3DLineRenderer } from "./Graphic3DLineBatchRenderer"; -import { BoundUtil } from "../../../../util/BoundUtil"; export class Graphic3D extends Object3D { protected mLineRender: Graphic3DLineRenderer; @@ -18,6 +9,7 @@ export class Graphic3D extends Object3D { constructor() { super(); + this.name = 'graphic3D'; this.mLineRender = this.addComponent(Graphic3DLineRenderer); this.mFillRender = this.addComponent(Graphic3DFillRenderer); } diff --git a/src/gfx/renderJob/passRenderer/graphic/Graphics3DShape.ts b/packages/graphic/renderer/Graphics3DShape.ts similarity index 97% rename from src/gfx/renderJob/passRenderer/graphic/Graphics3DShape.ts rename to packages/graphic/renderer/Graphics3DShape.ts index 274362a9..6d8b1ff6 100644 --- a/src/gfx/renderJob/passRenderer/graphic/Graphics3DShape.ts +++ b/packages/graphic/renderer/Graphics3DShape.ts @@ -1,6 +1,4 @@ -import { Color } from "../../../../math/Color"; -import { DEGREES_TO_RADIANS } from "../../../../math/MathUtil"; -import { Vector3 } from "../../../../math/Vector3"; +import { Color, DEGREES_TO_RADIANS, Vector3 } from "@orillusion/core"; /** * @internal diff --git a/packages/graphic/renderer/GrassRenderer.ts b/packages/graphic/renderer/GrassRenderer.ts index 2363a636..210a55d8 100644 --- a/packages/graphic/renderer/GrassRenderer.ts +++ b/packages/graphic/renderer/GrassRenderer.ts @@ -1,6 +1,9 @@ -import { ComputeShader, DynamicDrawStruct, DynamicFaceRenderer, Struct, graphicDynamicCompute } from "@orillusion/core"; +import { ComputeShader } from "@orillusion/core"; +import { graphicDynamicCompute } from "../compute/graphic3d/GraphicDynamicCompute"; import { GrassGeometryCompute_cs } from "../compute/grass/GrassGeometryCompute_cs"; +import { DynamicDrawStruct } from "./graphic3d/DynamicDrawStruct"; +import { DynamicFaceRenderer } from "./graphic3d/DynamicFaceRenderer"; export class GrassNodeStruct extends DynamicDrawStruct { grassCount: number = 1; diff --git a/packages/graphic/renderer/Shape3DMaker.ts b/packages/graphic/renderer/Shape3DMaker.ts index 00a88322..f820bc82 100644 --- a/packages/graphic/renderer/Shape3DMaker.ts +++ b/packages/graphic/renderer/Shape3DMaker.ts @@ -1,4 +1,4 @@ -import { BitmapTexture2DArray, Graphic3DMesh, Scene3D, Vector2, Vector3 } from "@orillusion/core"; +import { BitmapTexture2DArray, Scene3D, Vector2 } from "@orillusion/core"; import { Shape3DRenderer } from "./Shape3DRenderer"; import { RoundRectShape3D } from "./shape3d/RoundRectShape3D"; import { EllipseShape3D } from "./shape3d/EllipseShape3D"; @@ -9,6 +9,7 @@ import { QuadraticCurveShape3D } from "./shape3d/QuadraticCurveShape3D"; import { CurveShape3D } from "./shape3d/CurveShape3D"; import { Path2DShape3D } from "./shape3d/Path2DShape3D"; import { Path3DShape3D } from "./shape3d/Path3DShape3D"; +import { Graphic3DMesh } from "./graphic3d/Graphic3DMesh"; /** diff --git a/packages/graphic/renderer/Shape3DRenderer.ts b/packages/graphic/renderer/Shape3DRenderer.ts index 0439a0ba..a753d764 100644 --- a/packages/graphic/renderer/Shape3DRenderer.ts +++ b/packages/graphic/renderer/Shape3DRenderer.ts @@ -1,9 +1,12 @@ -import { BitmapTexture2DArray, ComputeShader, Ctor, DynamicDrawStruct, DynamicFaceRenderer, Matrix4, Object3D, OrderMap, StorageGPUBuffer, UniformGPUBuffer, Vector2, Vector3, Vector4, View3D, graphicDynamicCompute } from "@orillusion/core"; +import { BitmapTexture2DArray, ComputeShader, Ctor, Object3D, OrderMap, StorageGPUBuffer, UniformGPUBuffer, Vector3, Vector4, View3D } from "@orillusion/core"; import { Shape3DVertexCompute_cs } from "../compute/shape3d/Shape3DVertexCompute_cs"; import { Shape3DKeyPointCompute_cs } from "../compute/shape3d/Shape3DKeyPointCompute_cs"; import { Shape3D } from "./shape3d/Shape3D"; import { Shape3DVertexFillZero_cs } from "../compute/shape3d/Shape3DVertexFillZero_cs"; +import { DynamicFaceRenderer } from "./graphic3d/DynamicFaceRenderer"; +import { DynamicDrawStruct } from "./graphic3d/DynamicDrawStruct"; +import { graphicDynamicCompute } from "../compute/graphic3d/GraphicDynamicCompute"; export class Shape3DRenderer extends DynamicFaceRenderer { private _destPathBuffer: StorageGPUBuffer; diff --git a/src/gfx/renderJob/passRenderer/graphic/new/DynamicDrawStruct.ts b/packages/graphic/renderer/graphic3d/DynamicDrawStruct.ts similarity index 54% rename from src/gfx/renderJob/passRenderer/graphic/new/DynamicDrawStruct.ts rename to packages/graphic/renderer/graphic3d/DynamicDrawStruct.ts index e90103a2..ec77b4f3 100644 --- a/src/gfx/renderJob/passRenderer/graphic/new/DynamicDrawStruct.ts +++ b/packages/graphic/renderer/graphic3d/DynamicDrawStruct.ts @@ -1,4 +1,4 @@ -import { Struct } from "../../../../../util/struct/Struct"; +import { Struct } from "@orillusion/core"; export class DynamicDrawStruct extends Struct { // @NonSerialize diff --git a/src/gfx/renderJob/passRenderer/graphic/new/DynamicFaceRenderer.ts b/packages/graphic/renderer/graphic3d/DynamicFaceRenderer.ts similarity index 100% rename from src/gfx/renderJob/passRenderer/graphic/new/DynamicFaceRenderer.ts rename to packages/graphic/renderer/graphic3d/DynamicFaceRenderer.ts diff --git a/src/gfx/renderJob/passRenderer/graphic/new/Float32ArrayUtil.ts b/packages/graphic/renderer/graphic3d/Float32ArrayUtil.ts similarity index 86% rename from src/gfx/renderJob/passRenderer/graphic/new/Float32ArrayUtil.ts rename to packages/graphic/renderer/graphic3d/Float32ArrayUtil.ts index 88d59170..2f5e5e6d 100644 --- a/src/gfx/renderJob/passRenderer/graphic/new/Float32ArrayUtil.ts +++ b/packages/graphic/renderer/graphic3d/Float32ArrayUtil.ts @@ -1,4 +1,4 @@ -import { Vector4 } from "../../../../.."; +import { Vector4 } from "@orillusion/core"; export class Float32ArrayUtil { diff --git a/src/gfx/renderJob/passRenderer/graphic/new/Graphic3DFaceRenderer.ts b/packages/graphic/renderer/graphic3d/Graphic3DFaceRenderer.ts similarity index 85% rename from src/gfx/renderJob/passRenderer/graphic/new/Graphic3DFaceRenderer.ts rename to packages/graphic/renderer/graphic3d/Graphic3DFaceRenderer.ts index 4475b043..68ea5d7a 100644 --- a/src/gfx/renderJob/passRenderer/graphic/new/Graphic3DFaceRenderer.ts +++ b/packages/graphic/renderer/graphic3d/Graphic3DFaceRenderer.ts @@ -1,22 +1,7 @@ -import { GraphicLineCompute } from "../../../../../assets/shader/graphic/GraphicLineCompute"; -import { MeshRenderer } from "../../../../../components/renderer/MeshRenderer"; -import { View3D } from "../../../../../core/View3D"; -import { Object3D } from "../../../../../core/entities/Object3D"; -import { UnLitTexArrayMaterial } from "../../../../../materials/UnLitTexArrayMaterial"; -import { Color } from "../../../../../math/Color"; -import { Vector3 } from "../../../../../math/Vector3"; -import { Vector4 } from "../../../../../math/Vector4"; -import { TriGeometry } from "../../../../../shape/TriGeometry"; -import { BitmapTexture2DArray } from "../../../../../textures/BitmapTexture2DArray"; -import { GeometryUtil } from "../../../../../util/GeometryUtil"; -import { Struct } from "../../../../../util/struct/Struct"; -import { GlobalBindGroup } from "../../../../graphics/webGpu/core/bindGroups/GlobalBindGroup"; -import { StorageGPUBuffer } from "../../../../graphics/webGpu/core/buffer/StorageGPUBuffer"; -import { StructStorageGPUBuffer } from "../../../../graphics/webGpu/core/buffer/StructStorageGPUBuffer"; -import { ComputeShader } from "../../../../graphics/webGpu/shader/ComputeShader"; -import { GPUContext } from "../../../GPUContext"; -import { Float32ArrayUtil } from "./Float32ArrayUtil"; +import { Struct, MeshRenderer, BitmapTexture2DArray, StorageGPUBuffer, ComputeShader, StructStorageGPUBuffer, TriGeometry, UnLitTexArrayMaterial, Object3D, Color, Vector4, GlobalBindGroup, View3D, GPUContext } from "@orillusion/core"; import { ShapeInfo } from "./ShapeInfo"; +import { GraphicLineCompute } from "../../compute/graphic3d/GraphicLineCompute"; + export enum LineJoin { bevel = 0, diff --git a/src/gfx/renderJob/passRenderer/graphic/new/Graphic3DMesh.ts b/packages/graphic/renderer/graphic3d/Graphic3DMesh.ts similarity index 90% rename from src/gfx/renderJob/passRenderer/graphic/new/Graphic3DMesh.ts rename to packages/graphic/renderer/graphic3d/Graphic3DMesh.ts index 2f721311..ced66e6b 100644 --- a/src/gfx/renderJob/passRenderer/graphic/new/Graphic3DMesh.ts +++ b/packages/graphic/renderer/graphic3d/Graphic3DMesh.ts @@ -1,12 +1,8 @@ -import { Scene3D } from "../../../../../core/Scene3D"; -import { Object3D } from "../../../../../core/entities/Object3D"; -import { GeometryBase } from "../../../../../core/geometry/GeometryBase"; -import { BitmapTexture2DArray } from "../../../../../textures/BitmapTexture2DArray"; +import { GeometryBase, Scene3D, BitmapTexture2DArray, Object3D, Ctor } from "@orillusion/core"; import { Graphic3DMeshRenderer } from "./Graphic3DMeshRenderer"; import { Graphic3DRibbonRenderer } from "./Graphic3DRibbonRenderer"; import { Graphic3DFaceRenderer } from "./Graphic3DFaceRenderer"; import { DynamicFaceRenderer } from "./DynamicFaceRenderer"; -import { Ctor } from "../../../../.."; import { DynamicDrawStruct } from "./DynamicDrawStruct"; export class Graphic3DMesh { diff --git a/src/gfx/renderJob/passRenderer/graphic/new/Graphic3DMeshRenderer.ts b/packages/graphic/renderer/graphic3d/Graphic3DMeshRenderer.ts similarity index 76% rename from src/gfx/renderJob/passRenderer/graphic/new/Graphic3DMeshRenderer.ts rename to packages/graphic/renderer/graphic3d/Graphic3DMeshRenderer.ts index f45f0c1e..95f2aa36 100644 --- a/src/gfx/renderJob/passRenderer/graphic/new/Graphic3DMeshRenderer.ts +++ b/packages/graphic/renderer/graphic3d/Graphic3DMeshRenderer.ts @@ -1,16 +1,4 @@ -import { MeshRenderer } from "../../../../../components/renderer/MeshRenderer"; -import { View3D } from "../../../../../core/View3D"; -import { Object3D } from "../../../../../core/entities/Object3D"; -import { GeometryBase } from "../../../../../core/geometry/GeometryBase"; -import { UnLitTexArrayMaterial } from "../../../../../materials/UnLitTexArrayMaterial"; -import { Color } from "../../../../../math/Color"; -import { Vector3 } from "../../../../../math/Vector3"; -import { Vector4 } from "../../../../../math/Vector4"; -import { BitmapTexture2DArray } from "../../../../../textures/BitmapTexture2DArray"; -import { GeometryUtil } from "../../../../../util/GeometryUtil"; -import { StorageGPUBuffer } from "../../../../graphics/webGpu/core/buffer/StorageGPUBuffer"; -import { ComputeShader } from "../../../../graphics/webGpu/shader/ComputeShader"; -import { GPUContext } from "../../../GPUContext"; +import { MeshRenderer, StorageGPUBuffer, GeometryBase, BitmapTexture2DArray, Object3D, ComputeShader, UnLitTexArrayMaterial, Vector3, Color, Vector4, GeometryUtil, View3D, GPUContext } from "@orillusion/core"; export class Graphic3DMeshRenderer extends MeshRenderer { public transformBuffer: StorageGPUBuffer; diff --git a/src/gfx/renderJob/passRenderer/graphic/new/Graphic3DRibbonRenderer.ts b/packages/graphic/renderer/graphic3d/Graphic3DRibbonRenderer.ts similarity index 81% rename from src/gfx/renderJob/passRenderer/graphic/new/Graphic3DRibbonRenderer.ts rename to packages/graphic/renderer/graphic3d/Graphic3DRibbonRenderer.ts index f55d1581..03f37d35 100644 --- a/src/gfx/renderJob/passRenderer/graphic/new/Graphic3DRibbonRenderer.ts +++ b/packages/graphic/renderer/graphic3d/Graphic3DRibbonRenderer.ts @@ -1,22 +1,5 @@ -import { graphicTrailCompute } from "../../../../../assets/shader/graphic/GraphicTrailCompute"; -import { MeshRenderer } from "../../../../../components/renderer/MeshRenderer"; -import { View3D } from "../../../../../core/View3D"; -import { Object3D } from "../../../../../core/entities/Object3D"; -import { GeometryBase } from "../../../../../core/geometry/GeometryBase"; -import { UnLitTexArrayMaterial } from "../../../../../materials/UnLitTexArrayMaterial"; -import { Color } from "../../../../../math/Color"; -import { Vector2 } from "../../../../../math/Vector2"; -import { Vector4 } from "../../../../../math/Vector4"; -import { TrailGeometry } from "../../../../../shape/TrailGeometry"; -import { BitmapTexture2DArray } from "../../../../../textures/BitmapTexture2DArray"; -import { GeometryUtil } from "../../../../../util/GeometryUtil"; -import { NonSerialize } from "../../../../../util/SerializeDecoration"; -import { Struct } from "../../../../../util/struct/Struct"; -import { GlobalBindGroup } from "../../../../graphics/webGpu/core/bindGroups/GlobalBindGroup"; -import { StorageGPUBuffer } from "../../../../graphics/webGpu/core/buffer/StorageGPUBuffer"; -import { StructStorageGPUBuffer } from "../../../../graphics/webGpu/core/buffer/StructStorageGPUBuffer"; -import { ComputeShader } from "../../../../graphics/webGpu/shader/ComputeShader"; -import { GPUContext } from "../../../GPUContext"; +import { BitmapTexture2DArray, Color, ComputeShader, GeometryBase, GeometryUtil, GlobalBindGroup, GPUContext, MeshRenderer, NonSerialize, Object3D, StorageGPUBuffer, Struct, StructStorageGPUBuffer, TrailGeometry, UnLitTexArrayMaterial, Vector2, Vector4, View3D } from "@orillusion/core"; +import { graphicTrailCompute } from '../../compute/graphic3d/GraphicTrailCompute' export enum FaceMode { FaceToCamera, diff --git a/src/gfx/renderJob/passRenderer/graphic/new/ShapeInfo.ts b/packages/graphic/renderer/graphic3d/ShapeInfo.ts similarity index 73% rename from src/gfx/renderJob/passRenderer/graphic/new/ShapeInfo.ts rename to packages/graphic/renderer/graphic3d/ShapeInfo.ts index e5382527..3fd07745 100644 --- a/src/gfx/renderJob/passRenderer/graphic/new/ShapeInfo.ts +++ b/packages/graphic/renderer/graphic3d/ShapeInfo.ts @@ -1,6 +1,4 @@ -import { Vector4 } from "../../../../../math/Vector4"; -import { NonSerialize } from "../../../../../util/SerializeDecoration"; -import { Struct } from "../../../../../util/struct/Struct"; +import { NonSerialize, Struct, Vector4 } from "@orillusion/core"; export class ShapeInfo extends Struct { public shapeIndex: number = 0; //face,poly,line,cycle,rectangle,box,sphere diff --git a/packages/graphic/renderer/shape3d/LineShape3D.ts b/packages/graphic/renderer/shape3d/LineShape3D.ts index 39626e9f..237b27a8 100644 --- a/packages/graphic/renderer/shape3d/LineShape3D.ts +++ b/packages/graphic/renderer/shape3d/LineShape3D.ts @@ -1,4 +1,4 @@ -import { Vector3, LineJoin } from "@orillusion/core"; +import { LineJoin } from "../graphic3d/Graphic3DFaceRenderer"; import { Point3D, Shape3D, ShapeTypeEnum } from "./Shape3D"; import earcut from 'earcut'; diff --git a/packages/graphic/renderer/shape3d/Path3DShape3D.ts b/packages/graphic/renderer/shape3d/Path3DShape3D.ts index 7a6f0694..fc7bad5c 100644 --- a/packages/graphic/renderer/shape3d/Path3DShape3D.ts +++ b/packages/graphic/renderer/shape3d/Path3DShape3D.ts @@ -1,6 +1,7 @@ -import { Vector2, deg2Rad, Vector3, Matrix4, rad2Deg, LineJoin } from "@orillusion/core"; +import { Vector2, deg2Rad, Vector3, Matrix4, rad2Deg } from "@orillusion/core"; import { Point3D, Shape3DStruct, ShapeTypeEnum } from "./Shape3D"; import { LineShape3D } from "./LineShape3D"; +import { LineJoin } from "../graphic3d/Graphic3DFaceRenderer"; /** * Define class for drawing path in 3D space. diff --git a/packages/graphic/renderer/shape3d/Shape3D.ts b/packages/graphic/renderer/shape3d/Shape3D.ts index 09db4c89..45a23aaa 100644 --- a/packages/graphic/renderer/shape3d/Shape3D.ts +++ b/packages/graphic/renderer/shape3d/Shape3D.ts @@ -1,4 +1,5 @@ -import { DynamicDrawStruct, Matrix3, LineJoin, Vector2, Color, Vector4, Vector3 } from "@orillusion/core"; +import { Color, Vector4 } from "@orillusion/core"; +import { DynamicDrawStruct } from "../graphic3d/DynamicDrawStruct"; export class Shape3DStruct extends DynamicDrawStruct { public shapeType: number = 0; diff --git a/packages/graphic/tsconfig.json b/packages/graphic/tsconfig.json index 99cc83e4..69d04abd 100644 --- a/packages/graphic/tsconfig.json +++ b/packages/graphic/tsconfig.json @@ -25,6 +25,7 @@ "paths": { "@orillusion/core": ["../../src"], "@orillusion/*": ["../*"] - } + }, + "experimentalDecorators": true } } \ No newline at end of file diff --git a/samples/animation/Sample_CameraPathAnimation.ts b/samples/animation/Sample_CameraPathAnimation.ts index 2fe13b1f..56dc3568 100644 --- a/samples/animation/Sample_CameraPathAnimation.ts +++ b/samples/animation/Sample_CameraPathAnimation.ts @@ -1,5 +1,6 @@ import { Engine3D, Scene3D, View3D, Object3D, Color, Vector3, AtmosphericComponent, CameraUtil, HoverCameraController, DirectLight, KelvinUtil, Time, Object3DUtil, lerpVector3, Camera3D, AxisObject, ColliderComponent, PointerEvent3D, ComponentBase, Plane } from '@orillusion/core'; import { Stats } from '@orillusion/stats'; +import { Graphic3D } from '@orillusion/graphic'; import * as dat from 'dat.gui'; interface PathInfo { @@ -19,6 +20,7 @@ enum CameraModes { class Sample_CameraPathAnimation { view: View3D; camera: Camera3D; + graphic3D: Graphic3D; cameraMode = CameraModes.DualOrbit; guiControl: dat.GUIController; @@ -89,6 +91,10 @@ class Sample_CameraPathAnimation { view.camera = this.camera = camera; view.scene = scene; + // init Graphic3D to draw lines + this.graphic3D = new Graphic3D() + scene.addChild(this.graphic3D) + Engine3D.startRenderView(view); await this.initScene(scene, hoverCtrl); @@ -211,8 +217,8 @@ class Sample_CameraPathAnimation { pathInfo.curvePoints.splice(dataStartIndex, curveSegmentPoints.length, ...curveSegmentPoints); } - this.view.graphic3D.Clear(pathInfo.name); - this.view.graphic3D.drawLines(pathInfo.name, pathInfo.curvePoints, pathInfo.color); + this.graphic3D.Clear(pathInfo.name); + this.graphic3D.drawLines(pathInfo.name, pathInfo.curvePoints, pathInfo.color); } public generateOrUpdateCurve(points: Vector3[], samples: number = 20, tension: number = 0.5, indicesToUpdate?: number[]): Vector3[] { @@ -310,13 +316,13 @@ class Sample_CameraPathAnimation { const changeLine = (show: boolean) => { if (show) { - this.view.graphic3D.drawLines(this.cameraPathInfo.name, this.cameraPathInfo.curvePoints, this.cameraPathInfo.color); - this.view.graphic3D.drawLines(this.targetPathInfo.name, this.targetPathInfo.curvePoints, this.targetPathInfo.color); + this.graphic3D.drawLines(this.cameraPathInfo.name, this.cameraPathInfo.curvePoints, this.cameraPathInfo.color); + this.graphic3D.drawLines(this.targetPathInfo.name, this.targetPathInfo.curvePoints, this.targetPathInfo.color); console.log('camerabasePoints', this.cameraPathInfo.basePoints); console.log('targetbasePoints', this.targetPathInfo.basePoints); } else { - this.view.graphic3D.Clear(this.cameraPathInfo.name); - this.view.graphic3D.Clear(this.targetPathInfo.name); + this.graphic3D.Clear(this.cameraPathInfo.name); + this.graphic3D.Clear(this.targetPathInfo.name); } } } diff --git a/samples/base/Sample_BoundingBox.ts b/samples/base/Sample_BoundingBox.ts index 32b4183a..d0b83f5b 100644 --- a/samples/base/Sample_BoundingBox.ts +++ b/samples/base/Sample_BoundingBox.ts @@ -2,12 +2,14 @@ import { GUIHelp } from '@orillusion/debug/GUIHelp'; import { Color, Engine3D, Object3D, Object3DUtil, Transform, View3D, } from '@orillusion/core'; import { GUIUtil } from '@samples/utils/GUIUtil'; import { createExampleScene, createSceneParam } from '@samples/utils/ExampleScene'; +import { Graphic3D } from '@orillusion/graphic'; // A sample to show boundingbox class Sample_BoundingBox { view: View3D; box: Object3D; container: Object3D; + graphic3D: Graphic3D async run() { // init engine await Engine3D.init({ renderLoop: () => { this.loop() } }); @@ -25,6 +27,9 @@ class Sample_BoundingBox { this.box = box; this.view = exampleScene.view; + // add a graphic3D to draw lines + this.graphic3D = new Graphic3D(); + exampleScene.scene.addChild(this.graphic3D); let parent = this.container = new Object3D(); parent.addChild(box); @@ -46,8 +51,8 @@ class Sample_BoundingBox { red = new Color(1, 0, 0, 1); green = new Color(0, 1, 0, 1); loop() { - this.view.graphic3D.drawBoundingBox(this.box.instanceID, this.box.bound as any, this.green); - this.view.graphic3D.drawBoundingBox(this.container.instanceID, this.container.bound as any, this.red); + this.graphic3D.drawBoundingBox(this.box.instanceID, this.box.bound as any, this.green); + this.graphic3D.drawBoundingBox(this.container.instanceID, this.container.bound as any, this.red); } } diff --git a/samples/base/Sample_ComponentLife.ts b/samples/base/Sample_ComponentLife.ts index 4b7c2b95..b34f0d5d 100644 --- a/samples/base/Sample_ComponentLife.ts +++ b/samples/base/Sample_ComponentLife.ts @@ -1,6 +1,4 @@ import { Engine3D, Scene3D, CameraUtil, View3D, AtmosphericComponent, ComponentBase, Time, AxisObject, Object3DUtil, KelvinUtil, DirectLight, Object3D, HoverCameraController } from "@orillusion/core"; -import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { GUIUtil } from "@samples/utils/GUIUtil"; // sample use component class Sample_ComponentLife { diff --git a/samples/graphic/Sample_GraphicGrass.ts b/samples/graphic/Sample_GraphicGrass.ts index a70acc96..11a13f8f 100644 --- a/samples/graphic/Sample_GraphicGrass.ts +++ b/samples/graphic/Sample_GraphicGrass.ts @@ -1,7 +1,7 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, Graphic3DMesh, Matrix4, BlendMode, Color, Vector4, GeoJsonStruct, GeoJsonUtil, ShapeInfo, DynamicDrawStruct, Object3DUtil, PostProcessingComponent, GTAOPost } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, Matrix4, Color } from "@orillusion/core"; import { Stats } from "@orillusion/stats"; -import { GrassNodeStruct, GrassRenderer } from "@orillusion/graphic"; +import { GrassNodeStruct, GrassRenderer, Graphic3DMesh, Graphic3D } from "@orillusion/graphic"; @@ -10,6 +10,7 @@ export class Sample_GraphicGrass { scene: Scene3D; view: View3D; colors: Color[]; + graphic3D: Graphic3D constructor() { } async run() { @@ -39,14 +40,11 @@ export class Sample_GraphicGrass { this.view.scene = this.scene; this.view.camera = camera; - Engine3D.startRenderView(this.view); - - // GUIUtil.renderDebug(); + // add graphic3D to scene + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); - // let post = this.scene.addComponent(PostProcessingComponent); - // let bloom = post.addPost(GTAOPost); - // bloom.bloomIntensity = 1.0 - // GUIUtil.renderBloom(bloom); + Engine3D.startRenderView(this.view); await this.initScene(); @@ -64,47 +62,19 @@ export class Sample_GraphicGrass { directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); directLight.castShadow = false; directLight.intensity = 3; - // GUIUtil.renderDirLight(directLight); this.scene.addChild(this.lightObj3D); } - // let floor = Object3DUtil.GetSingleCube(3000, 1, 3000, 0.5, 0.5, 0.5); - // floor.y = -1; - // this.scene.addChild(floor); - - // let c1 = Object3DUtil.GetSingleCube(20, 20, 20, 0.85, 0.85, 0.85); - // this.scene.addChild(c1); - await this.addGrass(0); - // await this.addGrass(1); - // await this.addGrass(2); - // await this.addGrass(3); - // await this.addGrass(4); } private async addGrass(grassGroup: number) { let texts = []; - // texts.push(await Engine3D.res.loadTexture("terrain/grass/GrassRealistic.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture('terrain/test01/bitmap.png') as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/line3.png") as BitmapTexture2D); - - // texts.push(await Engine3D.res.loadTexture("terrain/grass/single.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("terrain/grass/single2.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("terrain/grass/single3.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("terrain/grass/GrassThick.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("terrain/grass/GrassRealistic.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/line4.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/grid.jpg") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/frame64.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/line_001064.png") as BitmapTexture2D); let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); bitmapTexture2DArray.setTextures(texts); { - // Unable to fix error related to missing GrassRenderer - // Leaving code as-is - let mr = Graphic3DMesh.drawNode( `path_geojson` + grassGroup, GrassRenderer, @@ -133,11 +103,10 @@ export class Sample_GraphicGrass { node.grassZ = Math.cos(angle) * radiu; } mr.updateShape(); - // Engine3D.views[0].graphic3D.drawFillCircle(`zero`, Vector3.ZERO, 0.5); } } update() { - Engine3D.views[0].graphic3D.drawCameraFrustum(Engine3D.views[0].camera); + this.graphic3D.drawCameraFrustum(Engine3D.views[0].camera); } } diff --git a/samples/graphic/Sample_GraphicLine.ts b/samples/graphic/Sample_GraphicLine.ts index 384d2958..6919cf3c 100644 --- a/samples/graphic/Sample_GraphicLine.ts +++ b/samples/graphic/Sample_GraphicLine.ts @@ -2,10 +2,12 @@ import { createExampleScene, createSceneParam } from "@samples/utils/ExampleScen import { Scene3D, Engine3D, Vector3, Color, AnimationCurve, Keyframe, View3D } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { GUIHelp } from "@orillusion/debug/GUIHelp"; +import { Graphic3D } from '@orillusion/graphic' class Sample_GraphicLine { scene: Scene3D; view: View3D; + graphic3D: Graphic3D; async run() { Engine3D.setting.material.materialChannelDebug = true; @@ -19,6 +21,10 @@ class Sample_GraphicLine { exampleScene.atmosphericSky.exposure = 1.0; this.view = exampleScene.view; this.scene = exampleScene.scene; + + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderViews([exampleScene.view]); let job = Engine3D.getRenderJob(exampleScene.view); await this.initScene(); @@ -27,9 +33,7 @@ class Sample_GraphicLine { } async initScene() { - this.view.graphic3D.drawLines('line1', [Vector3.ZERO, new Vector3(0, 10, 0)], new Color().hexToRGB(Color.RED)); - - + this.graphic3D.drawLines('line1', [Vector3.ZERO, new Vector3(0, 10, 0)], new Color().hexToRGB(Color.RED)); let animCurve = new AnimationCurve(); animCurve.addKeyFrame(new Keyframe(0, 0.5)); @@ -49,13 +53,11 @@ class Sample_GraphicLine { ) ); } - this.view.graphic3D.drawLines('line2', lines, new Color().hexToRGB(Color.RED)); - - this.view.graphic3D.drawBox('box1', new Vector3(-5, -5, -5), new Vector3(5, 5, 5), new Color().hexToRGB(Color.GREEN)); - - this.view.graphic3D.drawCircle('Circle1', new Vector3(-15, -5, -5), 5, 15, Vector3.X_AXIS, new Color().hexToRGB(Color.GREEN)); - this.view.graphic3D.drawCircle('Circle2', new Vector3(-15, -5, -5), 5, 15, Vector3.Y_AXIS, new Color().hexToRGB(Color.GREEN)); - this.view.graphic3D.drawCircle('Circle3', new Vector3(-15, -5, -5), 5, 15, Vector3.Z_AXIS, new Color().hexToRGB(Color.GREEN)); + this.graphic3D.drawLines('line2', lines, new Color().hexToRGB(Color.RED)); + this.graphic3D.drawBox('box1', new Vector3(-5, -5, -5), new Vector3(5, 5, 5), new Color().hexToRGB(Color.GREEN)); + this.graphic3D.drawCircle('Circle1', new Vector3(-15, -5, -5), 5, 15, Vector3.X_AXIS, new Color().hexToRGB(Color.GREEN)); + this.graphic3D.drawCircle('Circle2', new Vector3(-15, -5, -5), 5, 15, Vector3.Y_AXIS, new Color().hexToRGB(Color.GREEN)); + this.graphic3D.drawCircle('Circle3', new Vector3(-15, -5, -5), 5, 15, Vector3.Z_AXIS, new Color().hexToRGB(Color.GREEN)); } } diff --git a/samples/graphic/Sample_GraphicMeshWave.ts b/samples/graphic/Sample_GraphicMeshWave.ts index 32e67d24..00af841c 100644 --- a/samples/graphic/Sample_GraphicMeshWave.ts +++ b/samples/graphic/Sample_GraphicMeshWave.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, PrefabParser } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, Time, BlendMode, PrefabParser } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMeshWave { lightObj3D: Object3D; @@ -11,6 +12,7 @@ export class Sample_GraphicMeshWave { height: number; cafe: number = 47; frame: number = 16; + graphic3D: Graphic3D; constructor() { } @@ -22,9 +24,6 @@ export class Sample_GraphicMeshWave { await Engine3D.init({ beforeRender: () => this.update() }); Engine3D.setting.render.debug = true; - Engine3D.setting.shadow.shadowBound = 5; - - GUIHelp.init(); @@ -41,6 +40,9 @@ export class Sample_GraphicMeshWave { view.scene = this.scene; view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(view); GUIUtil.renderDebug(); @@ -65,9 +67,7 @@ export class Sample_GraphicMeshWave { } let texts = []; - texts.push(await Engine3D.res.loadTexture("textures/128/star_0031.png") as BitmapTexture2D); - let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); bitmapTexture2DArray.setTextures(texts); @@ -80,7 +80,6 @@ export class Sample_GraphicMeshWave { { this.width = 100; this.height = 100; - // let geometry = new BoxGeometry(1, 1, 1); let geometry = new PlaneGeometry(1, 1, 1, 1, Vector3.Z_AXIS); let mr = Graphic3DMesh.draw(this.scene, geometry, bitmapTexture2DArray, this.width * this.height); this.parts = mr.object3Ds; @@ -92,11 +91,7 @@ export class Sample_GraphicMeshWave { for (let i = 0; i < this.width * this.height; i++) { const element = this.parts[i]; - // mr.setTextureID(i, i % texts.length); - // mr.setTextureID(i, 52); - // mr.setTextureID(i, 35); mr.setTextureID(i, 0); - // mr.setTextureID(i, 18); let size = 1.0; element.transform.scaleX = size; @@ -113,7 +108,6 @@ export class Sample_GraphicMeshWave { const element = this.parts[i]; this.wave(i, pos); - element.transform.localPosition = pos; } } diff --git a/samples/graphic/Sample_GraphicMesh_0.ts b/samples/graphic/Sample_GraphicMesh_0.ts index 18ca0b2d..a8a713a4 100644 --- a/samples/graphic/Sample_GraphicMesh_0.ts +++ b/samples/graphic/Sample_GraphicMesh_0.ts @@ -1,7 +1,8 @@ +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, Time, BlendMode } from "@orillusion/core"; +import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from '@orillusion/graphic' import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; -import { Stats } from "@orillusion/stats"; export class Sample_GraphicMesh_0 { lightObj3D: Object3D; @@ -9,6 +10,7 @@ export class Sample_GraphicMesh_0 { parts: Object3D[]; width: number; height: number; + graphic3D: Graphic3D; cafe: number = 47; frame: number = 16; @@ -25,8 +27,6 @@ export class Sample_GraphicMesh_0 { Engine3D.setting.render.debug = true; Engine3D.setting.shadow.shadowBound = 5; - - GUIHelp.init(); this.scene = new Scene3D(); @@ -35,97 +35,25 @@ export class Sample_GraphicMesh_0 { sky.enable = false; let camera = CameraUtil.createCamera3DObject(this.scene); camera.perspective(60, Engine3D.aspect, 1, 5000.0); - camera.object3D.addComponent(HoverCameraController).setCamera(30, 0, 120); let view = new View3D(); view.scene = this.scene; view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(view); GUIUtil.renderDebug(); await this.initScene(); - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 3; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - let texts = []; - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0003.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0025.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0026.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0001.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0003.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0009.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0016.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0017.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0019.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0020.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0021.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0022.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0024.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0025.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0004.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0008.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0011.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0012.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0014.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0016.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/star_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0004.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0008.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0011.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0013.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0014.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0016.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0018.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0019.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0020.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0021.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0023.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0024.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0025.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0027.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0028.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0031.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0035.png") as BitmapTexture2D); - - // texts.push(Engine3D.res.grayTexture); - let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); bitmapTexture2DArray.setTextures(texts); @@ -136,51 +64,34 @@ export class Sample_GraphicMesh_0 { { this.width = 200; this.height = 100; - // let geometry = new BoxGeometry(1, 1, 1); let geometry = new PlaneGeometry(1, 1, 1, 1, Vector3.Z_AXIS); let mr = Graphic3DMesh.draw(this.scene, geometry, bitmapTexture2DArray, this.width * this.height); this.parts = mr.object3Ds; mr.material.blendMode = BlendMode.ADD; - // mr.material.doubleSide = true; mr.material.transparent = true; mr.material.depthWriteEnabled = false; mr.material.useBillboard = true; for (let i = 0; i < this.width * this.height; i++) { - const element = this.parts[i]; - // mr.setTextureID(i, i % texts.length); - // mr.setTextureID(i, 52); - mr.setTextureID(i, 35); - - - // mr.setTextureID(i, 39); - // mr.setTextureID(i, 18); + // const element = this.parts[i]; + mr.setTextureID(i, 0); } } } update() { if (this.parts) { - let pos = new Vector3(); + // let pos = new Vector3(); for (let i = 0; i < this.parts.length; i++) { const element = this.parts[i]; - let tmp = this.sphericalFibonacci(i, this.parts.length); tmp.scaleBy(Math.sin((i + Time.frame * 0.01)) * 50); - element.transform.localPosition = tmp; } } } - private wave(i: number, pos: Vector3) { - let x = Math.floor(i / this.width); - let z = i % this.height; - pos.set(x, 0, z); - pos.y = Math.sin((x + Time.frame * 0.01) / 8) * 15 * Math.cos((z + Time.frame * 0.01) / 15); - } - public madfrac(A: number, B: number): number { return A * B - Math.floor(A * B); } @@ -197,5 +108,4 @@ export class Sample_GraphicMesh_0 { cosTheta); } - } diff --git a/samples/graphic/Sample_GraphicMesh_1.ts b/samples/graphic/Sample_GraphicMesh_1.ts index 8493975c..0a734841 100644 --- a/samples/graphic/Sample_GraphicMesh_1.ts +++ b/samples/graphic/Sample_GraphicMesh_1.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, Time, BlendMode, Color } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_1 { lightObj3D: Object3D; @@ -12,6 +13,7 @@ export class Sample_GraphicMesh_1 { cafe: number = 47; frame: number = 16; view: View3D; + graphic3D: Graphic3D; colors: Color[]; @@ -44,90 +46,20 @@ export class Sample_GraphicMesh_1 { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); GUIUtil.renderDebug(); await this.initScene(); - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } let texts = []; - - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0003.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0025.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0026.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0001.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0003.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0009.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0016.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0017.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0019.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0020.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0021.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0022.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0024.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0025.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0004.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0008.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0011.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0012.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0014.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0016.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/star_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0004.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0008.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0011.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0013.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0014.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0016.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0018.png") as BitmapTexture2D); texts.push(await Engine3D.res.loadTexture("textures/128/star_0019.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0020.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0021.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0023.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0024.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0025.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0027.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0028.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0031.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0035.png") as BitmapTexture2D); - - // texts.push(Engine3D.res.grayTexture); - let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); bitmapTexture2DArray.setTextures(texts); @@ -140,32 +72,22 @@ export class Sample_GraphicMesh_1 { { this.width = 100; this.height = 100; - // let geometry = new BoxGeometry(1, 1, 1); let geometry = new PlaneGeometry(1, 1, 1, 1, Vector3.Z_AXIS); let mr = Graphic3DMesh.draw(this.scene, geometry, bitmapTexture2DArray, this.width * this.height); this.parts = mr.object3Ds; mr.material.blendMode = BlendMode.ADD; - // mr.material.doubleSide = true; mr.material.transparent = true; mr.material.depthWriteEnabled = false; mr.material.useBillboard = true; for (let i = 0; i < this.width * this.height; i++) { const element = this.parts[i]; - // mr.setTextureID(i, i % texts.length); - // mr.setTextureID(i, 52); - mr.setTextureID(i, 39); - // mr.setTextureID(i, 39); - // mr.setTextureID(i, 18); + mr.setTextureID(i, 0); element.transform.scaleX = 2; element.transform.scaleY = 2; element.transform.scaleZ = 2; - - // let c = Color.random(); - // c.a = 0.55; - // this.colors.push(c); } let c1 = new Color(0.65, 0.1, 0.2, 0.15); @@ -195,8 +117,8 @@ export class Sample_GraphicMesh_1 { } for (let i = 0; i < this.tmpArray.length - 1; i++) { - this.view.graphic3D.Clear(i.toString()); - this.view.graphic3D.drawLines(i.toString(), [ + this.graphic3D.Clear(i.toString()); + this.graphic3D.drawLines(i.toString(), [ this.tmpArray[i].transform.worldPosition, this.tmpArray[i + 1].transform.worldPosition, ], @@ -204,14 +126,6 @@ export class Sample_GraphicMesh_1 { } } } - - private wave(i: number, pos: Vector3) { - let x = Math.floor(i / this.width); - let z = i % this.height; - pos.set(x, 0, z); - pos.y = Math.sin((x + Time.frame * 0.01) / 8) * 15 * Math.cos((z + Time.frame * 0.01) / 15); - } - public madfrac(A: number, B: number): number { return A * B - Math.floor(A * B); } diff --git a/samples/graphic/Sample_GraphicMesh_2.ts b/samples/graphic/Sample_GraphicMesh_2.ts index ca9498e0..22b32eae 100644 --- a/samples/graphic/Sample_GraphicMesh_2.ts +++ b/samples/graphic/Sample_GraphicMesh_2.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, Time, BlendMode } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_2 { lightObj3D: Object3D; @@ -11,7 +12,7 @@ export class Sample_GraphicMesh_2 { height: number; cafe: number = 47; frame: number = 16; - + graphic3D: Graphic3D constructor() { } async run() { @@ -22,9 +23,6 @@ export class Sample_GraphicMesh_2 { await Engine3D.init({ beforeRender: () => this.update() }); Engine3D.setting.render.debug = true; - Engine3D.setting.shadow.shadowBound = 5; - - GUIHelp.init(); @@ -40,90 +38,20 @@ export class Sample_GraphicMesh_2 { let view = new View3D(); view.scene = this.scene; view.camera = camera; + + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); Engine3D.startRenderView(view); GUIUtil.renderDebug(); await this.initScene(); - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - let texts = []; - - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0003.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0025.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0026.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0001.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0003.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0009.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0016.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0017.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0019.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0020.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0021.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0022.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0024.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0025.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0004.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0008.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0011.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0012.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0014.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0016.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/star_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0004.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0008.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0011.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0013.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0014.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0016.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0018.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0019.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0020.png") as BitmapTexture2D); texts.push(await Engine3D.res.loadTexture("textures/128/star_0021.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0023.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0024.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0025.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0027.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0028.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0031.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0035.png") as BitmapTexture2D); - - // texts.push(Engine3D.res.grayTexture); let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); bitmapTexture2DArray.setTextures(texts); @@ -137,31 +65,25 @@ export class Sample_GraphicMesh_2 { { this.width = 200; this.height = 100; - // let geometry = new BoxGeometry(1, 1, 1); let geometry = new PlaneGeometry(1, 1, 1, 1, Vector3.Z_AXIS); let mr = Graphic3DMesh.draw(this.scene, geometry, bitmapTexture2DArray, this.width * this.height); this.parts = mr.object3Ds; mr.material.blendMode = BlendMode.ADD; - // mr.material.doubleSide = true; mr.material.transparent = true; mr.material.depthWriteEnabled = false; mr.material.useBillboard = true; for (let i = 0; i < this.width * this.height; i++) { - const element = this.parts[i]; - // mr.setTextureID(i, i % texts.length); - // mr.setTextureID(i, 52); + // const element = this.parts[i]; mr.setTextureID(i, 35); - // mr.setTextureID(i, 39); - // mr.setTextureID(i, 18); } } } update() { if (this.parts) { - let pos = new Vector3(); + // let pos = new Vector3(); for (let i = 0; i < this.parts.length; i++) { const element = this.parts[i]; @@ -180,13 +102,6 @@ export class Sample_GraphicMesh_2 { } } - private wave(i: number, pos: Vector3) { - let x = Math.floor(i / this.width); - let z = i % this.height; - pos.set(x, 0, z); - pos.y = Math.sin((x + Time.frame * 0.01) / 8) * 15 * Math.cos((z + Time.frame * 0.01) / 15); - } - public madfrac(A: number, B: number): number { return A * B - Math.floor(A * B); } diff --git a/samples/graphic/Sample_GraphicMesh_3.ts b/samples/graphic/Sample_GraphicMesh_3.ts index 26284fc2..6fb4021e 100644 --- a/samples/graphic/Sample_GraphicMesh_3.ts +++ b/samples/graphic/Sample_GraphicMesh_3.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, MeshRenderer, UnLitTexArrayMaterial, BitmapTexture2DArray, Vector3, Graphic3DMesh, Matrix4, Time, PrefabParser } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, MeshRenderer, UnLitTexArrayMaterial, BitmapTexture2DArray, Vector3, Matrix4, Time } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_3 { lightObj3D: Object3D; @@ -11,6 +12,7 @@ export class Sample_GraphicMesh_3 { height: number; cafe: number = 47; frame: number = 16; + graphic3D: Graphic3D; constructor() { } @@ -22,9 +24,6 @@ export class Sample_GraphicMesh_3 { await Engine3D.init({ beforeRender: () => this.update() }); Engine3D.setting.render.debug = true; - Engine3D.setting.shadow.shadowBound = 5; - - GUIHelp.init(); @@ -41,36 +40,20 @@ export class Sample_GraphicMesh_3 { view.scene = this.scene; view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(view); GUIUtil.renderDebug(); await this.initScene(); - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - let texts = []; - - PrefabParser.useWebp = false; let node = await Engine3D.res.loadGltf("gltfs/glb/beer.glb") as Object3D; let geo = node.getComponents(MeshRenderer)[0].geometry; - - // texts.push(await Engine3D.res.loadTexture("textures/128/star_0031.png") as BitmapTexture2D); texts.push(Engine3D.res.yellowTexture); let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); @@ -85,22 +68,12 @@ export class Sample_GraphicMesh_3 { { this.width = 100; this.height = 20; - // let geometry = new BoxGeometry(1, 1, 1); - // let geometry = new PlaneGeometry(1, 1, 1, 1, Vector3.Z_AXIS); let mr = Graphic3DMesh.draw(this.scene, geo, bitmapTexture2DArray, this.width * this.height); this.parts = mr.object3Ds; - // mr.material.blendMode = BlendMode.ADD; - // mr.material.transparent = true; - // mr.material.depthWriteEnabled = false; - for (let i = 0; i < this.width * this.height; i++) { const element = this.parts[i]; - // mr.setTextureID(i, i % texts.length); - // mr.setTextureID(i, 52); - // mr.setTextureID(i, 35); mr.setTextureID(i, 0); - // mr.setTextureID(i, 18); let size = Math.random() * 5.0 + 1.0; element.transform.scaleX = size; @@ -112,7 +85,7 @@ export class Sample_GraphicMesh_3 { update() { if (this.parts) { - let pos = new Vector3(); + // let pos = new Vector3(); for (let i = 0; i < this.parts.length; i++) { const element = this.parts[i]; @@ -131,13 +104,6 @@ export class Sample_GraphicMesh_3 { } } - private wave(i: number, pos: Vector3) { - let x = Math.floor(i / this.width); - let z = i % this.height; - pos.set(x, 0, z); - pos.y = Math.sin((x + Time.frame * 0.01) / 8) * 15 * Math.cos((z + Time.frame * 0.01) / 15); - } - public madfrac(A: number, B: number): number { return A * B - Math.floor(A * B); } diff --git a/samples/graphic/Sample_GraphicMesh_4.ts b/samples/graphic/Sample_GraphicMesh_4.ts index ae7424d1..d075efd0 100644 --- a/samples/graphic/Sample_GraphicMesh_4.ts +++ b/samples/graphic/Sample_GraphicMesh_4.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, PrefabParser } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, Time, BlendMode } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_4 { lightObj3D: Object3D; @@ -11,6 +12,7 @@ export class Sample_GraphicMesh_4 { height: number; cafe: number = 47; frame: number = 16; + graphic3D: Graphic3D; constructor() { } @@ -22,9 +24,6 @@ export class Sample_GraphicMesh_4 { await Engine3D.init({ beforeRender: () => this.update() }); Engine3D.setting.render.debug = true; - Engine3D.setting.shadow.shadowBound = 5; - - GUIHelp.init(); @@ -41,34 +40,19 @@ export class Sample_GraphicMesh_4 { view.scene = this.scene; view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(view); GUIUtil.renderDebug(); await this.initScene(); - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - let texts = []; - texts.push(await Engine3D.res.loadTexture("textures/128/star_0031.png") as BitmapTexture2D); - // texts.push(Engine3D.res.yellowTexture); - let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); bitmapTexture2DArray.setTextures(texts); diff --git a/samples/graphic/Sample_GraphicMesh_5.ts b/samples/graphic/Sample_GraphicMesh_5.ts index 2d1e48de..938d231a 100644 --- a/samples/graphic/Sample_GraphicMesh_5.ts +++ b/samples/graphic/Sample_GraphicMesh_5.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, Time, BlendMode, Color } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_5 { lightObj3D: Object3D; @@ -12,6 +13,7 @@ export class Sample_GraphicMesh_5 { cafe: number = 47; frame: number = 16; view: View3D; + graphic3D: Graphic3D; colors: Color[]; @@ -44,90 +46,19 @@ export class Sample_GraphicMesh_5 { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); GUIUtil.renderDebug(); await this.initScene(); - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - let texts = []; - - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0003.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0025.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/glow_0026.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0001.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0003.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0009.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0016.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0017.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0019.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0020.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0021.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0022.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0024.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/wave_0025.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0004.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0008.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0011.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0012.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0014.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/Vortex_0016.png") as BitmapTexture2D); - - texts.push(await Engine3D.res.loadTexture("textures/128/star_0002.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0004.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0005.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0006.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0007.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0008.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0010.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0011.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0013.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0014.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0016.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0018.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0019.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0020.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0021.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0023.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0024.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0025.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0027.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0028.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/128/star_0031.png") as BitmapTexture2D); texts.push(await Engine3D.res.loadTexture("textures/128/star_0035.png") as BitmapTexture2D); - - // texts.push(Engine3D.res.grayTexture); - let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); bitmapTexture2DArray.setTextures(texts); @@ -140,32 +71,21 @@ export class Sample_GraphicMesh_5 { { this.width = 100; this.height = 100; - // let geometry = new BoxGeometry(1, 1, 1); let geometry = new PlaneGeometry(1, 1, 1, 1, Vector3.Z_AXIS); let mr = Graphic3DMesh.draw(this.scene, geometry, bitmapTexture2DArray, this.width * this.height); this.parts = mr.object3Ds; mr.material.blendMode = BlendMode.ADD; - // mr.material.doubleSide = true; mr.material.transparent = true; mr.material.depthWriteEnabled = false; mr.material.useBillboard = true; for (let i = 0; i < this.width * this.height; i++) { const element = this.parts[i]; - // mr.setTextureID(i, i % texts.length); - // mr.setTextureID(i, 52); mr.setTextureID(i, 39); - // mr.setTextureID(i, 39); - // mr.setTextureID(i, 18); - element.transform.scaleX = 2; element.transform.scaleY = 2; element.transform.scaleZ = 2; - - // let c = Color.random(); - // c.a = 0.55; - // this.colors.push(c); } let c1 = new Color(0.65, 0.1, 0.2, 0.15); @@ -195,8 +115,8 @@ export class Sample_GraphicMesh_5 { } for (let i = 0; i < this.tmpArray.length - 1; i++) { - this.view.graphic3D.Clear(i.toString()); - this.view.graphic3D.drawLines(i.toString(), [ + this.graphic3D.Clear(i.toString()); + this.graphic3D.drawLines(i.toString(), [ this.tmpArray[i].transform.worldPosition, this.tmpArray[i + 1].transform.worldPosition, ], diff --git a/samples/graphic/Sample_GraphicMesh_6.ts b/samples/graphic/Sample_GraphicMesh_6.ts index 53f45ac1..6b270b7f 100644 --- a/samples/graphic/Sample_GraphicMesh_6.ts +++ b/samples/graphic/Sample_GraphicMesh_6.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, BlendMode, Color } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_6 { lightObj3D: Object3D; @@ -12,7 +13,7 @@ export class Sample_GraphicMesh_6 { cafe: number = 47; frame: number = 16; view: View3D; - + graphic3D: Graphic3D; colors: Color[]; constructor() { } @@ -22,7 +23,7 @@ export class Sample_GraphicMesh_6 { Matrix4.maxCount = 500000; Matrix4.allocCount = 500000; - await Engine3D.init({ beforeRender: () => this.update() }); + await Engine3D.init(); Engine3D.setting.render.debug = true; Engine3D.setting.shadow.shadowBound = 5; @@ -44,33 +45,19 @@ export class Sample_GraphicMesh_6 { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); GUIUtil.renderDebug(); await this.initScene(); - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - let texts = []; - texts.push(await Engine3D.res.loadTexture("textures/128/star_0008.png") as BitmapTexture2D); - let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); bitmapTexture2DArray.setTextures(texts); @@ -83,32 +70,22 @@ export class Sample_GraphicMesh_6 { { this.width = 15; this.height = 15; - // let geometry = new BoxGeometry(1, 1, 1); let geometry = new PlaneGeometry(1, 1, 1, 1, Vector3.Z_AXIS); let mr = Graphic3DMesh.draw(this.scene, geometry, bitmapTexture2DArray, this.width * this.height); this.parts = mr.object3Ds; mr.material.blendMode = BlendMode.ADD; - // mr.material.doubleSide = true; mr.material.transparent = true; mr.material.depthWriteEnabled = false; mr.material.useBillboard = true; for (let i = 0; i < this.width * this.height; i++) { const element = this.parts[i]; - // mr.setTextureID(i, i % texts.length); - // mr.setTextureID(i, 52); mr.setTextureID(i, 0); - // mr.setTextureID(i, 39); - // mr.setTextureID(i, 18); element.transform.scaleX = 5.5; element.transform.scaleY = 5.5; element.transform.scaleZ = 5.5; - - // let c = Color.random(); - // c.a = 0.55; - // this.colors.push(c); } let c1 = new Color(0.65, 0.1, 0.2, 0.15); @@ -117,16 +94,13 @@ export class Sample_GraphicMesh_6 { this.colors.push(c2); } - this.updateOnce(1000); + this.updateOnce(); } private tmpArray: any[] = []; - update() { - } - - updateOnce(engineFrame: number) { + updateOnce() { if (this.parts) { - let pos = new Vector3(); + // let pos = new Vector3(); this.tmpArray.length = 0; for (let i = 0; i < this.parts.length; i++) { const element = this.parts[i]; @@ -142,8 +116,8 @@ export class Sample_GraphicMesh_6 { } for (let i = 0; i < this.tmpArray.length - 1; i++) { - this.view.graphic3D.Clear(i.toString()); - this.view.graphic3D.drawLines(i.toString(), [ + this.graphic3D.Clear(i.toString()); + this.graphic3D.drawLines(i.toString(), [ Vector3.ZERO, this.tmpArray[i + 1].transform.worldPosition, ], diff --git a/samples/graphic/Sample_GraphicMesh_7.ts b/samples/graphic/Sample_GraphicMesh_7.ts index b753c7ea..29af3ded 100644 --- a/samples/graphic/Sample_GraphicMesh_7.ts +++ b/samples/graphic/Sample_GraphicMesh_7.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color, PostProcessingComponent, BloomPost } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, BlendMode, Color, PostProcessingComponent, BloomPost } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_7 { lightObj3D: Object3D; @@ -12,7 +13,7 @@ export class Sample_GraphicMesh_7 { cafe: number = 47; frame: number = 16; view: View3D; - + graphic3D: Graphic3D colors: Color[]; constructor() { } @@ -22,7 +23,7 @@ export class Sample_GraphicMesh_7 { Matrix4.maxCount = 500000; Matrix4.allocCount = 500000; - await Engine3D.init({ beforeRender: () => this.update() }); + await Engine3D.init(); Engine3D.setting.render.debug = true; Engine3D.setting.shadow.shadowBound = 5; @@ -44,6 +45,9 @@ export class Sample_GraphicMesh_7 { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); GUIUtil.renderDebug(); @@ -54,25 +58,9 @@ export class Sample_GraphicMesh_7 { GUIUtil.renderBloom(bloom); await this.initScene(); - - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - let texts = []; texts.push(await Engine3D.res.loadTexture("textures/128/star_0008.png") as BitmapTexture2D); @@ -116,14 +104,11 @@ export class Sample_GraphicMesh_7 { this.colors.push(c2); } - this.updateOnce(1000); + this.updateOnce(); } private tmpArray: any[] = []; - update() { - } - - updateOnce(engineFrame: number) { + updateOnce() { if (this.parts) { let pos = new Vector3(); this.tmpArray.length = 0; @@ -136,8 +121,8 @@ export class Sample_GraphicMesh_7 { } for (let i = 0; i < this.tmpArray.length / 3; i++) { - this.view.graphic3D.Clear(i.toString()); - this.view.graphic3D.drawLines(i.toString(), + this.graphic3D.Clear(i.toString()); + this.graphic3D.drawLines(i.toString(), [ this.tmpArray[i * 3 + 0].transform.worldPosition, this.tmpArray[i * 3 + 1].transform.worldPosition, diff --git a/samples/graphic/Sample_GraphicMesh_Color.ts b/samples/graphic/Sample_GraphicMesh_Color.ts deleted file mode 100644 index 4bfc06f7..00000000 --- a/samples/graphic/Sample_GraphicMesh_Color.ts +++ /dev/null @@ -1,173 +0,0 @@ -import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color, PostProcessingComponent, BloomPost, ColorUtil, Graphic3DMeshRenderer } from "@orillusion/core"; -import { GUIUtil } from "@samples/utils/GUIUtil"; -import { Stats } from "@orillusion/stats"; - -export class Sample_GraphicMesh_Color { - private lightObj3D: Object3D; - private scene: Scene3D; - private parts: Object3D[]; - private width: number; - private height: number; - private cafe: number = 47; - private frame: number = 16; - private view: View3D; - private colors: Color[]; - private tmpArray: any[] = []; - - private color1: Color ; - private color2: Color ; - graphicMeshRenderer: Graphic3DMeshRenderer; - - constructor() { } - - async run() { - - Matrix4.maxCount = 500000; - Matrix4.allocCount = 500000; - - await Engine3D.init({ beforeRender: () => this.update() }); - - Engine3D.setting.render.debug = true; - Engine3D.setting.shadow.shadowBound = 5; - - this.colors = []; - - GUIHelp.init(); - - this.scene = new Scene3D(); - this.scene.addComponent(Stats); - let sky = this.scene.addComponent(AtmosphericComponent); - sky.enable = false; - let camera = CameraUtil.createCamera3DObject(this.scene); - camera.perspective(60, Engine3D.aspect, 1, 5000.0); - - camera.object3D.addComponent(HoverCameraController).setCamera(30, 0, 120); - - this.view = new View3D(); - this.view.scene = this.scene; - this.view.camera = camera; - - Engine3D.startRenderView(this.view); - - GUIUtil.renderDebug(); - - let post = this.scene.addComponent(PostProcessingComponent); - let bloom = post.addPost(BloomPost); - bloom.bloomIntensity = 10.0 - GUIUtil.renderBloom(bloom); - - await this.initScene(); - - sky.relativeTransform = this.lightObj3D.transform; - } - - async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - - let texts = []; - - texts.push(await Engine3D.res.loadTexture("textures/128/star_0008.png") as BitmapTexture2D); - - let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); - bitmapTexture2DArray.setTextures(texts); - - let mat = new UnLitTexArrayMaterial(); - mat.baseMap = bitmapTexture2DArray; - mat.name = "LitMaterial"; - - GUIHelp.add(this, "cafe", 0.0, 100.0); - GUIHelp.add(this, "frame", 0.0, 100.0); - { - this.width = 15; - this.height = 15; - let geometry = new PlaneGeometry(1, 1, 1, 1, Vector3.Z_AXIS); - this.graphicMeshRenderer = Graphic3DMesh.draw(this.scene, geometry, bitmapTexture2DArray, this.width * this.height); - this.parts = this.graphicMeshRenderer.object3Ds; - - this.graphicMeshRenderer.material.blendMode = BlendMode.ADD; - this.graphicMeshRenderer.material.transparent = true; - this.graphicMeshRenderer.material.depthWriteEnabled = false; - this.graphicMeshRenderer.material.useBillboard = true; - - for (let i = 0; i < this.width * this.height; i++) { - const element = this.parts[i]; - this.graphicMeshRenderer.setTextureID(i, 0); - element.transform.scaleX = 5.5; - element.transform.scaleY = 5.5; - element.transform.scaleZ = 5.5; - } - - this.color1 = new Color(1.5, 0.1, 0.2, 1.0); - this.color2 = new Color(0.1, 0.1, 4.5, 1.0); - let c2 = new Color(1.0, 1.1, 0.2, 0.65); - this.colors.push(c2); - this.colors.push(c2); - this.colors.push(c2); - this.colors.push(c2); - this.colors.push(c2); - this.colors.push(c2); - } - - this.updateOnce(1000); - } - - update() { - this.updateOnce(Time.frame); - } - - updateOnce(engineFrame: number) { - if (this.parts) { - this.tmpArray.length = 0; - let len = this.parts.length ; - for (let i = 0; i < len; i++) { - const element = this.parts[i]; - let tmp = this.sphericalFibonacci(i, len); - tmp.scaleBy(this.cafe); - element.transform.localPosition = tmp; - this.tmpArray.push(element); - - let c = Color.lerp( Math.sin(engineFrame*0.001 + (i/len)), this.color1,this.color2, Color.COLOR_0 ); - this.graphicMeshRenderer.setBaseColor(i,c); - } - - for (let i = 0; i < this.tmpArray.length - 1; i++) { - this.view.graphic3D.Clear(i.toString()); - this.view.graphic3D.drawLines(i.toString(), [ - Vector3.ZERO, - this.tmpArray[i + 1].transform.worldPosition, - ], - this.colors); - } - } - } - - public madfrac(A: number, B: number): number { - return A * B - Math.floor(A * B); - } - - public sphericalFibonacci(i: number, n: number): Vector3 { - const PHI = Math.sqrt(5.0) * 0.5 + 0.5; - let phi = 2.0 * Math.PI * this.madfrac(i, PHI - 1); - let cosTheta = 1.0 - (2.0 * i + 1.0) * (1.0 / n); - let sinTheta = Math.sqrt(Math.max(Math.min(1.0 - cosTheta * cosTheta, 1.0), 0.0)); - - return new Vector3( - Math.cos(phi) * sinTheta, - Math.sin(phi) * sinTheta, - cosTheta); - } - -} diff --git a/samples/graphic/Sample_GraphicMesh_SpriteSheet.ts b/samples/graphic/Sample_GraphicMesh_SpriteSheet.ts index 03f21098..da73c3ee 100644 --- a/samples/graphic/Sample_GraphicMesh_SpriteSheet.ts +++ b/samples/graphic/Sample_GraphicMesh_SpriteSheet.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color, PostProcessingComponent, BloomPost, ColorUtil, Graphic3DMeshRenderer, UV } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Matrix4, Time, BlendMode, Color, PostProcessingComponent, BloomPost, Graphic3DMeshRenderer, UV } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_SpriteSheet { private lightObj3D: Object3D; @@ -17,6 +18,7 @@ export class Sample_GraphicMesh_SpriteSheet { private color1: Color; private color2: Color; + graphic3D: Graphic3D; graphicMeshRenderer: Graphic3DMeshRenderer; constructor() { } @@ -48,42 +50,18 @@ export class Sample_GraphicMesh_SpriteSheet { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); GUIUtil.renderDebug(); - let post = this.scene.addComponent(PostProcessingComponent); - let bloom = post.addPost(BloomPost); - bloom.bloomIntensity = 10.0 - GUIUtil.renderBloom(bloom); - await this.initScene(); - - sky.relativeTransform = this.lightObj3D.transform; } async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - let texts = []; - - // texts.push(await Engine3D.res.loadTexture("textures/spriteSheet/sequence_0031.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/spriteSheet/sequence_0050.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/spriteSheet/sequence_0036.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/spriteSheet/sequence_0053.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/spriteSheet/sequence_0041.png") as BitmapTexture2D); texts.push(await Engine3D.res.loadTexture("textures/spriteSheet/sequence_0040.png") as BitmapTexture2D); let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); @@ -143,15 +121,13 @@ export class Sample_GraphicMesh_SpriteSheet { tmp.scaleBy(this.cafe); element.transform.localPosition = tmp; this.tmpArray.push(element); - - // let c = Color.lerp(Math.sin(engineFrame * 0.001 + (i / len)), this.color1, this.color2, Color.COLOR_0); - // this.graphicMeshRenderer.setBaseColor(i, c); + // update uv this.graphicMeshRenderer.setUVRect(i, UV.getUVSheet((i / len) * 100 + engineFrame * 0.08, 3, 3)); } for (let i = 0; i < this.tmpArray.length - 1; i++) { - this.view.graphic3D.Clear(i.toString()); - this.view.graphic3D.drawLines(i.toString(), [ + this.graphic3D.Clear(i.toString()); + this.graphic3D.drawLines(i.toString(), [ Vector3.ZERO, this.tmpArray[i + 1].transform.worldPosition, ], diff --git a/samples/graphic/Sample_Shape3D.ts b/samples/graphic/Sample_Shape3D.ts index 2e941853..60a4cb6d 100644 --- a/samples/graphic/Sample_Shape3D.ts +++ b/samples/graphic/Sample_Shape3D.ts @@ -1,7 +1,7 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, Graphic3DMesh, Matrix4, Color, Time, sin, MeshRenderer, Vector2, LineJoin, Vector4, Object3DUtil, AxisObject } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, BitmapTexture2DArray, BitmapTexture2D, Matrix4, Color, Time, Vector2, Vector4, Object3DUtil, AxisObject } from "@orillusion/core"; import { Stats } from "@orillusion/stats"; -import { CircleShape3D, EllipseShape3D, Shape3DMaker, Shape3D } from "@orillusion/graphic"; +import { Graphic3D, CircleShape3D, EllipseShape3D, Shape3DMaker, Shape3D, LineJoin } from "@orillusion/graphic"; import { GUIShape3D } from "@samples/utils/GUIShape3D"; import { GUIUtil } from "@samples/utils/GUIUtil"; @@ -16,6 +16,7 @@ export class Sample_Shape3D { lightObj3D: Object3D; scene: Scene3D; view: View3D; + graphic3D: Graphic3D; async run() { @@ -41,6 +42,9 @@ export class Sample_Shape3D { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); await this.initScene(); diff --git a/samples/graphic/Sample_Shape3DPath2D.ts b/samples/graphic/Sample_Shape3DPath2D.ts index 9014a72f..d5927e25 100644 --- a/samples/graphic/Sample_Shape3DPath2D.ts +++ b/samples/graphic/Sample_Shape3DPath2D.ts @@ -1,7 +1,7 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, Graphic3DMesh, Matrix4, Color, Time, sin, MeshRenderer, Vector2, LineJoin, Vector4, Object3DUtil, AxisObject } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, BitmapTexture2DArray, BitmapTexture2D, Matrix4, Color, Vector4, Object3DUtil, AxisObject } from "@orillusion/core"; import { Stats } from "@orillusion/stats"; -import { Shape3DMaker, Shape3D } from "@orillusion/graphic"; +import { Shape3DMaker, Shape3D, LineJoin, Graphic3D } from "@orillusion/graphic"; import { GUIShape3D } from "@samples/utils/GUIShape3D"; @@ -39,7 +39,7 @@ export class Sample_Shape3DPath2D { this.view = new View3D(); this.view.scene = this.scene; this.view.camera = camera; - + Engine3D.startRenderView(this.view); await this.initScene(); diff --git a/samples/graphic/Sample_Shape3DPath3D.ts b/samples/graphic/Sample_Shape3DPath3D.ts index 76251268..b752a1b9 100644 --- a/samples/graphic/Sample_Shape3DPath3D.ts +++ b/samples/graphic/Sample_Shape3DPath3D.ts @@ -1,10 +1,9 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, BitmapTexture2DArray, BitmapTexture2D, Matrix4, Color, LineJoin, Vector4, Object3DUtil, AxisObject } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, BitmapTexture2DArray, BitmapTexture2D, Matrix4, Color, Vector4, Object3DUtil, AxisObject } from "@orillusion/core"; import { Stats } from "@orillusion/stats"; -import { Shape3DMaker, Shape3D } from "@orillusion/graphic"; +import { Shape3DMaker, Shape3D, LineJoin } from "@orillusion/graphic"; import { GUIShape3D } from "@samples/utils/GUIShape3D"; - /** * This example shows how to use Shape3D to draw various different paths in 3D space. * diff --git a/samples/graphic/_Sample_GraphicShape.ts b/samples/graphic/_Sample_GraphicShape.ts deleted file mode 100644 index ba5b3e50..00000000 --- a/samples/graphic/_Sample_GraphicShape.ts +++ /dev/null @@ -1,155 +0,0 @@ -import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, Graphic3DMesh, Matrix4, BlendMode, Color, Vector4, LineJoin, GeoJsonStruct, GeoJsonUtil, ShapeInfo } from "@orillusion/core"; -import { Stats } from "@orillusion/stats"; - -export class _Sample_GraphicShape { - lightObj3D: Object3D; - scene: Scene3D; - parts: Object3D[]; - width: number; - height: number; - cafe: number = 47; - frame: number = 16; - view: View3D; - - colors: Color[]; - trail3ds: Object3D[][]; - - constructor() { } - - async run() { - - Matrix4.maxCount = 10000; - Matrix4.allocCount = 10000; - - await Engine3D.init({ beforeRender: () => this.update() }); - - Engine3D.setting.render.debug = true; - Engine3D.setting.shadow.shadowBound = 5; - - this.colors = []; - - GUIHelp.init(); - - this.scene = new Scene3D(); - this.scene.addComponent(Stats); - let sky = this.scene.addComponent(AtmosphericComponent); - sky.enable = false; - let camera = CameraUtil.createCamera3DObject(this.scene); - camera.perspective(60, Engine3D.aspect, 1, 5000.0); - - camera.object3D.addComponent(HoverCameraController).setCamera(30, -60, 25); - - this.view = new View3D(); - this.view.scene = this.scene; - this.view.camera = camera; - - Engine3D.startRenderView(this.view); - - // GUIUtil.renderDebug(); - - // let post = this.scene.addComponent(PostProcessingComponent); - // let bloom = post.addPost(BloomPost); - // bloom.bloomIntensity = 1.0 - // GUIUtil.renderBloom(bloom); - - await this.initScene(); - - sky.relativeTransform = this.lightObj3D.transform; - } - - async initScene() { - /******** light *******/ - { - this.lightObj3D = new Object3D(); - this.lightObj3D.rotationX = 21; - this.lightObj3D.rotationY = 108; - this.lightObj3D.rotationZ = 10; - let directLight = this.lightObj3D.addComponent(DirectLight); - directLight.lightColor = KelvinUtil.color_temperature_to_rgb(5355); - directLight.castShadow = false; - directLight.intensity = 10; - // GUIUtil.renderDirLight(directLight); - this.scene.addChild(this.lightObj3D); - } - - // let geoJsonData = await Engine3D.res.loadJSON("gis/geojson/pudong.geoJson") as GeoJsonStruct; - let geoJsonData = await Engine3D.res.loadJSON("gis/geojson/100000.geoJson") as GeoJsonStruct; - - let texts = []; - // texts.push(await Engine3D.res.loadTexture("textures/line.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/line2.png") as BitmapTexture2D); - texts.push(await Engine3D.res.loadTexture("textures/line3.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/line4.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/grid.jpg") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/frame64.png") as BitmapTexture2D); - // texts.push(await Engine3D.res.loadTexture("textures/line_001064.png") as BitmapTexture2D); - - - - let bitmapTexture2DArray = new BitmapTexture2DArray(texts[0].width, texts[0].height, texts.length); - bitmapTexture2DArray.setTextures(texts); - - let mat = new UnLitTexArrayMaterial(); - mat.baseMap = bitmapTexture2DArray; - mat.name = "LitMaterial"; - mat.blendMode = BlendMode.SOFT_ADD; - - let mat4 = new Matrix4(); - mat4.rawData.set([]); - - GUIHelp.add(this, "cafe", 0.0, 100.0); - GUIHelp.add(this, "frame", 0.0, 100.0); - { - this.width = 1; - this.height = 1; - - let neg = true; - - let lineArray = GeoJsonUtil.getPath(geoJsonData); - let mr = Graphic3DMesh.drawShape(`path_geojson`, this.scene, bitmapTexture2DArray); - for (let i = 0; i < this.width * this.height; i++) { - mr.setTextureID(i, Math.floor(Math.random() * texts.length)); - } - - // for (let ii = 0; ii < 1; ii++) { - for (let ii = 0; ii < lineArray.length; ii++) { - this.parts = mr.object3Ds; - - let shapeInfo = new ShapeInfo(); - shapeInfo.shapeType = 3; - shapeInfo.lineJoin = LineJoin.bevel; - shapeInfo.width = 0.25; - shapeInfo.uScale = 1; - shapeInfo.vScale = 10; - shapeInfo.uSpeed = 0; - shapeInfo.vSpeed = 6; - mr.setShape(ii, shapeInfo); - let tmp = []; - for (let i = 0; i < lineArray[ii].length; i++) { - let p = lineArray[ii][i]; - let newPos = new Vector4(); - newPos.set(p.x - 121, p.y, p.z - 31, 0.0); - tmp.push(newPos); - newPos.multiplyScalar(25); - mr.shapes[ii].paths.push(newPos); - } - - // mr.shapes[ii].paths.push(new Vector4(0.0, 0.0, 0.0)); - // mr.shapes[ii].paths.push(new Vector4(1.0, 0.0, 0.0)); - // mr.shapes[ii].paths.push(new Vector4(2.0, 0.0, 5.0)); - // mr.shapes[ii].paths.push(new Vector4(4.0, 0.0, 2.0)); - // mr.shapes[ii].paths.push(new Vector4(8.0, 0.0, 2.0)); - // mr.shapes[ii].paths.push(new Vector4(10.0, 0.0, 5.0)); - console.log(`path${ii}`, tmp.length); - // Engine3D.views[0].graphic3D.drawLines(`path${ii}`, tmp); - } - mr.updateShape(); - // Engine3D.views[0].graphic3D.drawFillCircle(`zero`, Vector3.ZERO, 0.5); - - } - } - - update() { - } -} diff --git a/samples/graphic/_Sample_GraphicTrailing.ts b/samples/graphic/_Sample_GraphicTrailing.ts index 488fa6ca..6771f136 100644 --- a/samples/graphic/_Sample_GraphicTrailing.ts +++ b/samples/graphic/_Sample_GraphicTrailing.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color, PostProcessingComponent, BloomPost, TrailGeometry, AnimationCurve, Keyframe, AnimationCurveT, KeyframeT, DepthOfFieldPost } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, Vector3, Matrix4, BlendMode, Color, PostProcessingComponent, BloomPost, AnimationCurve, Keyframe } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_Trailing { lightObj3D: Object3D; @@ -12,6 +13,7 @@ export class Sample_GraphicMesh_Trailing { cafe: number = 47; frame: number = 16; view: View3D; + graphic3D: Graphic3D; colors: Color[]; trail3ds: Object3D[]; @@ -45,24 +47,19 @@ export class Sample_GraphicMesh_Trailing { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); GUIUtil.renderDebug(); let post = this.scene.addComponent(PostProcessingComponent); - // let DOFPost = post.addPost(DepthOfFieldPost) - // DOFPost.near = 0 - // DOFPost.far = 150 - // DOFPost.pixelOffset = 2 - // GUIUtil.renderDepthOfField(DOFPost); - let bloom = post.addPost(BloomPost); bloom.bloomIntensity = 10.0 GUIUtil.renderBloom(bloom); await this.initScene(); - - // sky.relativeTransform = this.lightObj3D.transform; } async initScene() { diff --git a/samples/graphic/_Sample_GraphicTrailing2.ts b/samples/graphic/_Sample_GraphicTrailing2.ts index 602a614a..2c94aac2 100644 --- a/samples/graphic/_Sample_GraphicTrailing2.ts +++ b/samples/graphic/_Sample_GraphicTrailing2.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color, PostProcessingComponent, BloomPost, TrailGeometry, AnimationCurve, Keyframe, AnimationCurveT, KeyframeT, DepthOfFieldPost, Quaternion } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, Vector3, Matrix4, BlendMode, Color, PostProcessingComponent, BloomPost } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D, Graphic3DMesh } from "@orillusion/graphic"; export class Sample_GraphicMesh_Trailing2 { lightObj3D: Object3D; @@ -12,7 +13,7 @@ export class Sample_GraphicMesh_Trailing2 { cafe: number = 47; frame: number = 16; view: View3D; - + graphic3D: Graphic3D; colors: Color[]; trail3ds: Object3D[]; @@ -45,24 +46,19 @@ export class Sample_GraphicMesh_Trailing2 { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); GUIUtil.renderDebug(); let post = this.scene.addComponent(PostProcessingComponent); - // let DOFPost = post.addPost(DepthOfFieldPost) - // DOFPost.near = 0 - // DOFPost.far = 150 - // DOFPost.pixelOffset = 2 - // GUIUtil.renderDepthOfField(DOFPost); - let bloom = post.addPost(BloomPost); bloom.bloomIntensity = 10.0 GUIUtil.renderBloom(bloom); await this.initScene(); - - // sky.relativeTransform = this.lightObj3D.transform; } async initScene() { diff --git a/samples/graphic/_Sample_GraphicTrailing3.ts b/samples/graphic/_Sample_GraphicTrailing3.ts index 0ea0c634..20b763b7 100644 --- a/samples/graphic/_Sample_GraphicTrailing3.ts +++ b/samples/graphic/_Sample_GraphicTrailing3.ts @@ -1,7 +1,8 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; -import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, SphereGeometry, VirtualTexture, GPUTextureFormat, UnLitMaterial, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, PlaneGeometry, Vector3, Graphic3DMesh, Matrix4, Time, BlendMode, Color, PostProcessingComponent, BloomPost, TrailGeometry, AnimationCurve, Keyframe, AnimationCurveT, KeyframeT, DepthOfFieldPost, Quaternion } from "@orillusion/core"; +import { Object3D, Scene3D, Engine3D, AtmosphericComponent, CameraUtil, HoverCameraController, View3D, DirectLight, KelvinUtil, UnLitTexArrayMaterial, BitmapTexture2DArray, BitmapTexture2D, Vector3, Matrix4, BlendMode, Color, PostProcessingComponent, BloomPost } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; import { Stats } from "@orillusion/stats"; +import { Graphic3D } from "@orillusion/graphic"; export class Sample_GraphicTrailing3 { lightObj3D: Object3D; @@ -12,6 +13,7 @@ export class Sample_GraphicTrailing3 { cafe: number = 47; frame: number = 16; view: View3D; + graphic3D: Graphic3D; colors: Color[]; trail3ds: Object3D[]; @@ -45,24 +47,19 @@ export class Sample_GraphicTrailing3 { this.view.scene = this.scene; this.view.camera = camera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + Engine3D.startRenderView(this.view); GUIUtil.renderDebug(); let post = this.scene.addComponent(PostProcessingComponent); - // let DOFPost = post.addPost(DepthOfFieldPost) - // DOFPost.near = 0 - // DOFPost.far = 150 - // DOFPost.pixelOffset = 2 - // GUIUtil.renderDepthOfField(DOFPost); - let bloom = post.addPost(BloomPost); bloom.bloomIntensity = 10.0 GUIUtil.renderBloom(bloom); await this.initScene(); - - // sky.relativeTransform = this.lightObj3D.transform; } async initScene() { diff --git a/samples/lights/Sample_CSM.ts b/samples/lights/Sample_CSM.ts index ea95f85f..10c5a621 100644 --- a/samples/lights/Sample_CSM.ts +++ b/samples/lights/Sample_CSM.ts @@ -1,6 +1,7 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; import { Scene3D, HoverCameraController, Engine3D, AtmosphericComponent, Object3D, Camera3D, Vector3, View3D, DirectLight, KelvinUtil, LitMaterial, MeshRenderer, BoxGeometry, CameraUtil, SphereGeometry, Color, Object3DUtil, BlendMode } from "@orillusion/core"; import { GUIUtil } from "@samples/utils/GUIUtil"; +import { Graphic3D } from "@orillusion/graphic"; //sample of csm class Sample_CSM { @@ -9,6 +10,7 @@ class Sample_CSM { light: DirectLight; boxRenderer: MeshRenderer; viewCamera: Camera3D; + graphic3D: Graphic3D; async run() { Engine3D.setting.shadow.autoUpdate = true; Engine3D.setting.shadow.shadowSize = 2048; @@ -37,6 +39,9 @@ class Sample_CSM { this.view = view; this.viewCamera = mainCamera; + this.graphic3D = new Graphic3D(); + this.scene.addChild(this.graphic3D); + mainCamera.enableCSM = true; GUIHelp.addFolder('CSM') GUIHelp.add(mainCamera, 'enableCSM'); @@ -139,7 +144,7 @@ class Sample_CSM { this._shadowPos.copy(light.direction).normalize(viewCamera.far); csmBound.center.add(this._shadowPos, this._shadowCameraTarget); csmBound.center.subtract(this._shadowPos, this._shadowPos); - view.graphic3D.drawLines('shadowLine', [this._shadowPos, this._shadowCameraTarget], new Color(1, 1, 0, 1)); + this.graphic3D.drawLines('shadowLine', [this._shadowPos, this._shadowCameraTarget], new Color(1, 1, 0, 1)); } } diff --git a/samples/octree/Sample_OctTreeBox.ts b/samples/octree/Sample_OctTreeBox.ts index a053da8e..1981efb7 100644 --- a/samples/octree/Sample_OctTreeBox.ts +++ b/samples/octree/Sample_OctTreeBox.ts @@ -1,12 +1,12 @@ import { GUIHelp } from '@orillusion/debug/GUIHelp'; -import { BoundingBox, BoxGeometry, Color, Engine3D, LitMaterial, MeshRenderer, Object3D, Object3DUtil, PointerEvent3D, Time, Vector3, View3D, } from '@orillusion/core'; +import { BoundingBox, BoxGeometry, Color, Engine3D, LitMaterial, MeshRenderer, Object3D, Octree, OctreeEntity, Vector3, View3D, } from '@orillusion/core'; import { createExampleScene, createSceneParam } from '@samples/utils/ExampleScene'; -import { OctreeEntity } from '../../src/core/tree/octree/OctreeEntity'; -import { Octree } from '../../src/core/tree/octree/Octree'; +import { Graphic3D } from '@orillusion/graphic'; // A sample to use octTree export class Sample_OctTreeBox { view: View3D; + graphic3D: Graphic3D; entities: OctreeEntity[] = []; tree: Octree; red = new Color(1, 0, 0, 1); @@ -31,6 +31,9 @@ export class Sample_OctTreeBox { this.view = exampleScene.view; + this.graphic3D = new Graphic3D(); + exampleScene.scene.addChild(this.graphic3D); + let box: BoundingBox = new BoundingBox(); box.setFromMinMax(new Vector3(-100, -100, -100), new Vector3(100, 100, 100)); this.tree = new Octree(box); @@ -105,7 +108,7 @@ export class Sample_OctTreeBox { for (let item of this.entities) { item.renderer.enable = retBoolean[item.uuid]; } - this.view.graphic3D.drawBoundingBox('pick', this.movingBox, this.green); + this.graphic3D.drawBoundingBox('pick', this.movingBox, this.green); } loop() { diff --git a/samples/octree/Sample_OctTreeFrustum.ts b/samples/octree/Sample_OctTreeFrustum.ts index 9dff8c23..39c01f01 100644 --- a/samples/octree/Sample_OctTreeFrustum.ts +++ b/samples/octree/Sample_OctTreeFrustum.ts @@ -1,14 +1,14 @@ import { GUIHelp } from '@orillusion/debug/GUIHelp'; -import { BoundingBox, BoxGeometry, Camera3D, Color, Engine3D, LitMaterial, MeshRenderer, Object3D, Object3DUtil, PointerEvent3D, Time, Vector3, View3D, } from '@orillusion/core'; +import { BoundingBox, BoxGeometry, Camera3D, Color, Engine3D, LitMaterial, MeshRenderer, Object3D, Object3DUtil, Octree, OctreeEntity, PointerEvent3D, Time, Vector3, View3D, } from '@orillusion/core'; import { createExampleScene, createSceneParam } from '@samples/utils/ExampleScene'; -import { OctreeEntity } from '../../src/core/tree/octree/OctreeEntity'; -import { Octree } from '../../src/core/tree/octree/Octree'; import { GUIUtil } from '@samples/utils/GUIUtil'; import { Stats } from '@orillusion/stats'; +import { Graphic3D } from '@orillusion/graphic'; // A sample to use octTree export class Sample_OctTreeFrustum { view: View3D; + graphic3D: Graphic3D; entities: OctreeEntity[] = []; tree: Octree; red = new Color(1, 0, 0, 1); @@ -36,6 +36,9 @@ export class Sample_OctTreeFrustum { this.view = exampleScene.view; this.view.scene.addComponent(Stats); + this.graphic3D = new Graphic3D(); + this.view.scene.addChild(this.graphic3D); + let box: BoundingBox = new BoundingBox(); box.setFromCenterAndSize(new Vector3(), new Vector3(1000, 1000, 1000)); this.tree = new Octree(box); @@ -82,8 +85,8 @@ export class Sample_OctTreeFrustum { private queryResult: OctreeEntity[] = []; private octreeTest() { - this.view.graphic3D.ClearAll(); - this.view.graphic3D.drawCameraFrustum(this.camera, this.green); + this.graphic3D.ClearAll(); + this.graphic3D.drawCameraFrustum(this.camera, this.green); // this.view.graphic3D.drawBoundingBox('box', this.camera.frustum.boudingBox, this.red); // this.camera.frustum.csm.name = 'sdfdf'; // for (let block of this.camera.frustum.csm.children) { diff --git a/samples/octree/Sample_OctTreeRay.ts b/samples/octree/Sample_OctTreeRay.ts index 9da97b8d..832a0ae8 100644 --- a/samples/octree/Sample_OctTreeRay.ts +++ b/samples/octree/Sample_OctTreeRay.ts @@ -1,12 +1,12 @@ import { GUIHelp } from '@orillusion/debug/GUIHelp'; -import { BoundingBox, BoxGeometry, Color, Engine3D, LitMaterial, MeshRenderer, Object3D, Object3DUtil, PointerEvent3D, Time, Vector3, View3D, } from '@orillusion/core'; +import { BoundingBox, BoxGeometry, Color, Engine3D, LitMaterial, MeshRenderer, Object3D, Object3DUtil, Octree, OctreeEntity, PointerEvent3D, Time, Vector3, View3D, } from '@orillusion/core'; import { createExampleScene, createSceneParam } from '@samples/utils/ExampleScene'; -import { OctreeEntity } from '../../src/core/tree/octree/OctreeEntity'; -import { Octree } from '../../src/core/tree/octree/Octree'; +import { Graphic3D } from '@orillusion/graphic'; // A sample to use octTree export class Sample_OctTreeRay { view: View3D; + graphic3D: Graphic3D; entities: OctreeEntity[] = []; tree: Octree; red = new Color(1, 0, 0, 1); @@ -31,6 +31,8 @@ export class Sample_OctTreeRay { Engine3D.getRenderJob(exampleScene.view); this.view = exampleScene.view; + this.graphic3D = new Graphic3D(); + this.view.scene.addChild(this.graphic3D); let box: BoundingBox = new BoundingBox(); box.setFromCenterAndSize(new Vector3(), new Vector3(400, 400, 400)); @@ -79,7 +81,7 @@ export class Sample_OctTreeRay { this.tree.rayCasts(ray, this.queryResult); let time: number = Date.now() - now; console.log('time: ' + time + ' count: ', this.queryResult.length); - this.view.graphic3D.ClearAll(); + this.graphic3D.ClearAll(); let retBoolean = {}; let boundList = {}; @@ -96,7 +98,7 @@ export class Sample_OctTreeRay { //show box for (let key in boundList) { let tree = boundList[key]; - this.view.graphic3D.drawBoundingBox(key, tree.box, this.green); + this.graphic3D.drawBoundingBox(key, tree.box, this.green); } } diff --git a/samples/utils/GUIShape3D.ts b/samples/utils/GUIShape3D.ts index da3a5100..469666a6 100644 --- a/samples/utils/GUIShape3D.ts +++ b/samples/utils/GUIShape3D.ts @@ -1,6 +1,6 @@ import { GUIHelp } from "@orillusion/debug/GUIHelp"; import { CircleShape3D, CurveShape3D, EllipseShape3D, QuadraticCurveShape3D, RoundRectShape3D, LineShape3D, Shape3D, CircleArcType, Path2DShape3D, Path3DShape3D } from "@orillusion/graphic"; -import { LineJoin } from "@orillusion/core"; +import { LineJoin } from "@orillusion/graphic"; import { GUIUtil } from "./GUIUtil"; export class GUIShape3D { diff --git a/src/components/lights/Light.ts b/src/components/lights/Light.ts index 98c37489..3a67cca3 100644 --- a/src/components/lights/Light.ts +++ b/src/components/lights/Light.ts @@ -109,7 +109,10 @@ export class Light extends LightBase { } public onGraphic(view?: View3D): void { - let custom = view.graphic3D.createCustomShape( + let graphic3D = view.scene.getChildByName('graphic3D') + if(!graphic3D) + return + let custom = graphic3D.createCustomShape( `PointLight_${this.object3D.instanceID}`, this.transform, ); diff --git a/src/components/lights/PointLight.ts b/src/components/lights/PointLight.ts index 51a97899..aeb2284e 100644 --- a/src/components/lights/PointLight.ts +++ b/src/components/lights/PointLight.ts @@ -108,7 +108,10 @@ export class PointLight extends LightBase { } public onGraphic(view?: View3D): void { - // let custom = view.graphic3D.createCustomShape( + // let graphic3D = view.scene.getChildByName('graphic3D') + // if(!graphic3D) + // return + // let custom = graphic3D.createCustomShape( // `PointLight_${this.object3D.instanceID}`, // this.transform, // ); diff --git a/src/components/lights/SpotLight.ts b/src/components/lights/SpotLight.ts index fb63c999..0a8506a2 100644 --- a/src/components/lights/SpotLight.ts +++ b/src/components/lights/SpotLight.ts @@ -124,7 +124,10 @@ export class SpotLight extends LightBase { } public onGraphic(view: View3D) { - // let custom = view.graphic3D.createCustomShape( + // let graphic3D = view.scene.getChildByName('graphic3D') + // if(!graphic3D) + // return + // let custom = graphic3D.createCustomShape( // `SpotLight_${this.object3D.instanceID}`, // this.transform, // ); diff --git a/src/components/renderer/MeshRenderer.ts b/src/components/renderer/MeshRenderer.ts index 8208f7eb..23ab95ab 100644 --- a/src/components/renderer/MeshRenderer.ts +++ b/src/components/renderer/MeshRenderer.ts @@ -159,7 +159,10 @@ export class MeshRenderer extends RenderNode { } // public onGraphic(view?: View3D) { + // let graphic3D = view.scene.getChildByName('graphic3D') + // if(!graphic3D) + // return // if (this._geometry) - // view.graphic3D.drawMeshWireframe(this._geometry.instanceID, this._geometry, this.transform, Color.COLOR_RED); + // graphic3D.drawMeshWireframe(this._geometry.instanceID, this._geometry, this.transform, Color.COLOR_RED); // } } diff --git a/src/core/View3D.ts b/src/core/View3D.ts index c90ec262..01cc6c8b 100644 --- a/src/core/View3D.ts +++ b/src/core/View3D.ts @@ -3,7 +3,6 @@ import { GUIPick } from "../components/gui/GUIPick"; import { GUICanvas } from "../components/gui/core/GUICanvas"; import { CEventListener } from "../event/CEventListener"; import { ShadowLightsCollect } from "../gfx/renderJob/collect/ShadowLightsCollect"; -import { Graphic3D } from "../gfx/renderJob/passRenderer/graphic/Graphic3DRender"; import { PickFire } from "../io/PickFire"; import { Vector4 } from "../math/Vector4"; import { Camera3D } from "./Camera3D"; @@ -19,16 +18,10 @@ export class View3D extends CEventListener { public guiPick: GUIPick; public readonly canvasList: GUICanvas[]; - /** - * Graphics renderers (lines, rectangles, etc.) - */ - public graphic3D: Graphic3D; - constructor(x: number = 0, y: number = 0, width: number = 0, height: number = 0) { super(); this.canvasList = []; this._viewPort = new Vector4(x, y, width, height); - this.graphic3D = new Graphic3D(); } public get enable(): boolean { @@ -61,9 +54,6 @@ export class View3D extends CEventListener { ShadowLightsCollect.createBuffer(this); - if (this.graphic3D) - value.addChild(this.graphic3D); - if (value) { this.canvasList.forEach(canvas => { canvas && value.addChild(canvas.object3D); @@ -114,8 +104,4 @@ export class View3D extends CEventListener { } } - // public get graphic3D(): Graphic3D { - // return Engine3D.getRenderJob(this).graphic3D; - // } - } \ No newline at end of file diff --git a/src/gfx/renderJob/collect/EntityCollect.ts b/src/gfx/renderJob/collect/EntityCollect.ts index 8ce2ea57..c43d80e1 100644 --- a/src/gfx/renderJob/collect/EntityCollect.ts +++ b/src/gfx/renderJob/collect/EntityCollect.ts @@ -13,7 +13,7 @@ import { Vector3 } from '../../../math/Vector3'; import { zSorterUtil } from '../../../util/ZSorterUtil'; import { RenderLayerUtil, RenderLayer } from '../config/RenderLayer'; import { Probe } from '../passRenderer/ddgi/Probe'; -import { Graphic3DBatchRenderer } from '../passRenderer/graphic/Graphic3DBatchRenderer'; +// import { Graphic3DBatchRenderer } from '../passRenderer/graphic/Graphic3DBatchRenderer'; import { RendererMask } from '../passRenderer/state/RendererMask'; import { CollectInfo } from './CollectInfo'; import { EntityBatchCollect } from './EntityBatchCollect'; @@ -35,7 +35,7 @@ export class EntityCollect { private _octreeRenderNodes: Map; private _reflections: Map; - private _graphics: Graphic3DBatchRenderer[]; + private _graphics: RenderNode[]; private _op_renderGroup: Map; private _tr_renderGroup: Map; @@ -117,7 +117,7 @@ export class EntityCollect { if (!maps.includes(renderNode as Reflection)) { maps.push(renderNode as Reflection); } - } else if (renderNode instanceof Graphic3DBatchRenderer) { + } else if (renderNode.hasMask(RendererMask.Graphic3D)) { if (this._graphics.indexOf(renderNode) == -1) { this._graphics.push(renderNode); } @@ -315,7 +315,7 @@ export class EntityCollect { return this._tr_renderGroup.get(scene); } - public getGraphicList(): Graphic3DBatchRenderer[] { + public getGraphicList(): RenderNode[] { return this._graphics; } diff --git a/src/gfx/renderJob/passRenderer/state/RendererMask.ts b/src/gfx/renderJob/passRenderer/state/RendererMask.ts index 702e6b64..164e00a6 100644 --- a/src/gfx/renderJob/passRenderer/state/RendererMask.ts +++ b/src/gfx/renderJob/passRenderer/state/RendererMask.ts @@ -13,6 +13,7 @@ export enum RendererMask { UI = 1 << 7, Reflection = 1 << 8, ReflectionDebug = 1 << 9, + Graphic3D = 1 << 10 } /** diff --git a/src/index.ts b/src/index.ts index 03684f4d..18fa8bea 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,15 +67,6 @@ export * from "./assets/shader/env/ReflectionCG" export * from "./assets/shader/glsl/Quad_glsl" export * from "./assets/shader/glsl/Sky_glsl" export * from "./assets/shader/glsl/post/LUT_glsl" -export * from "./assets/shader/graphic/Graphic3DShader" -export * from "./assets/shader/graphic/GraphicDecCompute" -export * from "./assets/shader/graphic/GraphicDynamicCompute" -export * from "./assets/shader/graphic/GraphicFaceComput2" -export * from "./assets/shader/graphic/GraphicFaceCompute" -export * from "./assets/shader/graphic/GraphicFaceCompute3" -export * from "./assets/shader/graphic/GraphicLineCompute" -export * from "./assets/shader/graphic/GraphicTrailCompute" -export * from "./assets/shader/graphic/GraphicTrailCompute2" export * from "./assets/shader/lighting/BRDF_frag" export * from "./assets/shader/lighting/BsDF_frag" export * from "./assets/shader/lighting/BxDF_frag" @@ -360,20 +351,6 @@ export * from "./gfx/renderJob/passRenderer/ddgi/DDGILightingPass" export * from "./gfx/renderJob/passRenderer/ddgi/DDGIMultiBouncePass" export * from "./gfx/renderJob/passRenderer/ddgi/DDGIProbeRenderer" export * from "./gfx/renderJob/passRenderer/ddgi/Probe" -export * from "./gfx/renderJob/passRenderer/graphic/Graphic3DBatchRenderer" -export * from "./gfx/renderJob/passRenderer/graphic/Graphic3DFillRenderer" -export * from "./gfx/renderJob/passRenderer/graphic/Graphic3DFixedRenderMaterial" -export * from "./gfx/renderJob/passRenderer/graphic/Graphic3DLineBatchRenderer" -export * from "./gfx/renderJob/passRenderer/graphic/Graphic3DRender" -export * from "./gfx/renderJob/passRenderer/graphic/Graphics3DShape" -export * from "./gfx/renderJob/passRenderer/graphic/new/DynamicDrawStruct" -export * from "./gfx/renderJob/passRenderer/graphic/new/DynamicFaceRenderer" -export * from "./gfx/renderJob/passRenderer/graphic/new/Float32ArrayUtil" -export * from "./gfx/renderJob/passRenderer/graphic/new/Graphic3DFaceRenderer" -export * from "./gfx/renderJob/passRenderer/graphic/new/Graphic3DMesh" -export * from "./gfx/renderJob/passRenderer/graphic/new/Graphic3DMeshRenderer" -export * from "./gfx/renderJob/passRenderer/graphic/new/Graphic3DRibbonRenderer" -export * from "./gfx/renderJob/passRenderer/graphic/new/ShapeInfo" export * from "./gfx/renderJob/passRenderer/post/PostRenderer" export * from "./gfx/renderJob/passRenderer/preDepth/PreDepthPassRenderer" export * from "./gfx/renderJob/passRenderer/preDepth/ZCullingCompute" diff --git a/src/loader/parser/prefab/prefabData/APatch.ts b/src/loader/parser/prefab/prefabData/APatch.ts index f55bee6f..d834ed8f 100644 --- a/src/loader/parser/prefab/prefabData/APatch.ts +++ b/src/loader/parser/prefab/prefabData/APatch.ts @@ -16,19 +16,19 @@ export class APatch extends ComponentBase { public aPaths: number[]; public onGraphic(view?: View3D) { - return; - - // for (let i = this.size.x ; i > 0 ; i--) { - for (let i = 0; i < this.size.x; i++) { - for (let j = 0; j < this.size.y; j++) { - let index = j * this.size.x + (i); - let data = this.aPaths[index]; - let color = this.colors[data] ; + // let graphic3D = view.scene.getChildByName('graphic3D') + // if(!graphic3D) + // return + // // for (let i = this.size.x ; i > 0 ; i--) { + // for (let i = 0; i < this.size.x; i++) { + // for (let j = 0; j < this.size.y; j++) { + // let index = j * this.size.x + (i); + // let data = this.aPaths[index]; + // let color = this.colors[data] ; - let pos = new Vector3(-i * this.blockSize + this.object3D.x , 0 + this.object3D.y , j * this.blockSize+ this.object3D.z); - view.graphic3D.drawFillRect(`${i}-${j}` , pos , this.blockSize , this.blockSize, color ); - } - } - + // let pos = new Vector3(-i * this.blockSize + this.object3D.x , 0 + this.object3D.y , j * this.blockSize+ this.object3D.z); + // graphic3D.drawFillRect(`${i}-${j}` , pos , this.blockSize , this.blockSize, color ); + // } + // } } } \ No newline at end of file