Skip to content

Commit

Permalink
release v0.8.4
Browse files Browse the repository at this point in the history
## [0.8.4](v0.8.3...v0.8.4) (2024-11-27)


### Bug Fixes

* **destroy:** render error after obj.destroy() ([1e79847](1e79847))
* **extrudeGeometry:** fix shape in CCW order ([a7c8d01](a7c8d01))
* **frameRate:** render on small frameRate ([8b685b9](8b685b9))
* **geometry:** CylinderGeometry non-manifold ([#451](#451)) ([bf14c61](bf14c61))
* **graphic3d:** fix graphic clear & destroy ([eff6082](eff6082))
* **graphics3D:** fix buildCircle with custom up ([8e0354a](8e0354a))
* **pick:** add pick info in bound mode ([3fba2c5](3fba2c5))
* **pick:** add worldNormal in bound pick ([4b5bc9c](4b5bc9c))
* resolve issue with resume() being invoked multiple times ([9b2d7d1](9b2d7d1))
* **type:** refine PointerEvents types ([3029b5c](3029b5c))


### Features

* [WIP] double precision matrix support ([52ab9c5](52ab9c5))
* **ExtrudeGeometry:** add anchor point offset ([#452](#452)) ([fc2303d](fc2303d))
  • Loading branch information
lslzl3000 authored Nov 27, 2024
2 parents fc3614e + 2e46fd2 commit 8887427
Show file tree
Hide file tree
Showing 65 changed files with 603 additions and 507 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
## [0.8.4](https://github.com/Orillusion/orillusion/compare/v0.8.3...v0.8.4) (2024-11-27)


### Bug Fixes

* **destroy:** render error after obj.destroy() ([1e79847](https://github.com/Orillusion/orillusion/commit/1e798475f06dea6ee078469147c8f5da10d85ff0))
* **extrudeGeometry:** fix shape in CCW order ([a7c8d01](https://github.com/Orillusion/orillusion/commit/a7c8d01bfe956530dd774024acff005fa2d5163f))
* **frameRate:** render on small frameRate ([8b685b9](https://github.com/Orillusion/orillusion/commit/8b685b99ffbf345355bce7f977484a4ce091c25c))
* **geometry:** CylinderGeometry non-manifold ([#451](https://github.com/Orillusion/orillusion/issues/451)) ([bf14c61](https://github.com/Orillusion/orillusion/commit/bf14c612caae5e36661151c019990e3d9fffa5c6))
* **graphic3d:** fix graphic clear & destroy ([eff6082](https://github.com/Orillusion/orillusion/commit/eff6082495e85b14ca7baf313d2693e295eda06f))
* **graphics3D:** fix buildCircle with custom up ([8e0354a](https://github.com/Orillusion/orillusion/commit/8e0354adbdb2043a41541f06c437cd1acf850b30))
* **pick:** add pick info in bound mode ([3fba2c5](https://github.com/Orillusion/orillusion/commit/3fba2c55db3ac0320811f8792392e5042c32811d))
* **pick:** add worldNormal in bound pick ([4b5bc9c](https://github.com/Orillusion/orillusion/commit/4b5bc9c2d4bad5778fe24156763af0fe9347d2ec))
* resolve issue with resume() being invoked multiple times ([9b2d7d1](https://github.com/Orillusion/orillusion/commit/9b2d7d1eb23059dabdbd2e289c7464d231c0e597))
* **type:** refine PointerEvents types ([3029b5c](https://github.com/Orillusion/orillusion/commit/3029b5cc940ed140dcd4d05b4a3b76a8c270cda5))


### Features

* [WIP] double precision matrix support ([52ab9c5](https://github.com/Orillusion/orillusion/commit/52ab9c53d54f29b4c8de751ae616a1e0218b00a9))
* **ExtrudeGeometry:** add anchor point offset ([#452](https://github.com/Orillusion/orillusion/issues/452)) ([fc2303d](https://github.com/Orillusion/orillusion/commit/fc2303da4d948551d102309cbeb9d9dda762cb83))


## [0.8.3](https://github.com/Orillusion/orillusion/compare/v0.8.2...v0.8.3) (2024-08-28)


Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orillusion/core",
"version": "0.8.3",
"version": "0.8.4",
"author": "Orillusion",
"description": "Orillusion WebGPU Engine",
"type": "module",
Expand Down Expand Up @@ -54,7 +54,7 @@
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
},
"devDependencies": {
"@webgpu/types": "^0.1.40",
"@webgpu/types": "^0.1.45",
"conventional-changelog-cli": "^2.2.2",
"electron": "^31.1.0",
"typedoc": "^0.25.7",
Expand Down
132 changes: 101 additions & 31 deletions packages/geometry/ExtrudeGeometry/ExtrudeGeometry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GeometryBase, Vector2, VertexAttributeName } from "@orillusion/core";
import { GeometryBase, Vector2, Vector3, VertexAttributeName } from "@orillusion/core";
import { Shape2D } from "./Shape2D";
import { ShapeUtils } from "./ShapeUtils";

Expand All @@ -11,6 +11,7 @@ export type ExtrudeGeometryArgs = {
bevelSize?: number;
bevelOffset?: number;
bevelSegments?: number;
anchorPoint?: Vector3;
}

export class ExtrudeGeometry extends GeometryBase {
Expand All @@ -19,7 +20,7 @@ export class ExtrudeGeometry extends GeometryBase {
protected verticesArray: number[] = [];
protected uvArray: number[] = [];

constructor(shapes?: Shape2D[], options?) {
constructor(shapes?: Shape2D[], options?: ExtrudeGeometryArgs) {
super();
this.options = options;
this.shapes = shapes;
Expand All @@ -28,17 +29,54 @@ export class ExtrudeGeometry extends GeometryBase {
}
}

protected getExtractPointsAndBoundingSize(shapes: Shape2D[], options: ExtrudeGeometryArgs): { BoundingSize: { min: Vector3; max: Vector3; }, ShapePoints: { shape: Vector2[]; holes: Vector2[][]; }[] } {
const depth: number = options.depth !== undefined ? options.depth : 1;
const curveSegments: number = options.curveSegments !== undefined ? options.curveSegments : 12;
let minPoint: Vector3 = new Vector3(Infinity, Infinity, depth > 0 ? 0 : depth);
let maxPoint: Vector3 = new Vector3(-Infinity, -Infinity, depth < 0 ? 0 : depth);
let shapePointsArray = [];
for (let shape of this.shapes) {
const shapePoints = shape.extractPoints(curveSegments);
shapePointsArray.push(shapePoints);
let vertices = shapePoints.shape;
for (let i = 0; i < vertices.length; i++) {
const p = vertices[i];
if (p.x < minPoint.x)
minPoint.x = p.x;
if (p.y < minPoint.y)
minPoint.y = p.y;

if (p.x > maxPoint.x)
maxPoint.x = p.x;
if (p.y > maxPoint.y)
maxPoint.y = p.y;
}
}

return {
ShapePoints: shapePointsArray,
BoundingSize: { min: minPoint, max: maxPoint },
}
}

protected buildGeometry(options: ExtrudeGeometryArgs) {
this.verticesArray = [];
this.uvArray = [];

let anchorPoint: Vector3 = options.anchorPoint !== undefined ? options.anchorPoint : new Vector3(0, 0, 0.5);
const result = this.getExtractPointsAndBoundingSize(this.shapes, options);
const offsetSize = result.BoundingSize.min.subtract(result.BoundingSize.max);
offsetSize.multiply(anchorPoint, offsetSize);

for (let shape of this.shapes) {
this.addShape(shape, options);
this.addShape(shape, options, offsetSize);
}

const indices = new Uint32Array(this.verticesArray.length / 3);
for (let i = 0; i < indices.length; i++) {
for (let i = 0; i < indices.length; i+=3) {
indices[i] = i;
indices[i + 1] = i + 2;
indices[i + 2] = i + 1;
}

this.setIndices(indices);
Expand All @@ -61,7 +99,7 @@ export class ExtrudeGeometry extends GeometryBase {
});
}

protected addShape(shape: Shape2D, options: ExtrudeGeometryArgs) {
protected addShape(shape: Shape2D, options: ExtrudeGeometryArgs, offsetSize: Vector3) {
const verticesArray = this.verticesArray;
const uvArray = this.uvArray;
const self = this;
Expand All @@ -87,15 +125,31 @@ export class ExtrudeGeometry extends GeometryBase {
const shapePoints = shape.extractPoints(curveSegments);
let vertices = shapePoints.shape;
const holes = shapePoints.holes;
const reverse = !ShapeUtils.isClockWise(vertices);

for (let i = 0; i < vertices.length; i++) {
const p = vertices[i];
p.x += offsetSize.x;
p.y += offsetSize.y;
}
for (let i = 0; i < holes.length; i++) {
const holeV = holes[i];
for (let j = 0; j < holeV.length; j++) {
const p = holeV[j];
p.x += offsetSize.x;
p.y += offsetSize.y;
}
}

// make sure shape is CW
const reverse = !ShapeUtils.isClockWise(vertices);
if (reverse) {
vertices = vertices.reverse();
for (let i = 0; i < holes.length; i++) {
const hole = holes[i];
if (ShapeUtils.isClockWise(hole)) {
holes[i] = hole.reverse();
}
}
// make sure hole is CCW
for (let i = 0; i < holes.length; i++) {
const hole = holes[i];
if (ShapeUtils.isClockWise(hole)) {
holes[i] = hole.reverse();
}
}

Expand Down Expand Up @@ -137,29 +191,29 @@ export class ExtrudeGeometry extends GeometryBase {

for (let i = 0; i < contour.length; i++) {
const vert = this.scalePoint2(contour[i], contourMovements[i], bs);
v(vert.x, vert.y, - z);
v(vert.x, vert.y, - z + offsetSize.z);
}

for (let h = 0, hl = holes.length; h < hl; h++) {
const ahole = holes[h];
oneHoleMovements = holesMovements[h];
for (let i = 0; i < ahole.length; i++) {
const vert = this.scalePoint2(ahole[i], oneHoleMovements[i], bs);
v(vert.x, vert.y, - z);
v(vert.x, vert.y, - z + offsetSize.z);
}
}
}

const bs = bevelSize + bevelOffset;
for (let i = 0; i < vlen; i++) {
const vert = bevelEnabled ? this.scalePoint2(vertices[i], verticesMovements[i], bs) : vertices[i];
v(vert.x, vert.y, 0);
v(vert.x, vert.y, 0 + offsetSize.z);
}

for (let s = 1; s <= steps; s++) {
for (let i = 0; i < vlen; i++) {
const vert = bevelEnabled ? this.scalePoint2(vertices[i], verticesMovements[i], bs) : vertices[i];
v(vert.x, vert.y, depth / steps * s);
v(vert.x, vert.y, depth / steps * s + offsetSize.z);
}
}

Expand All @@ -170,15 +224,15 @@ export class ExtrudeGeometry extends GeometryBase {

for (let i = 0, il = contour.length; i < il; i++) {
const vert = this.scalePoint2(contour[i], contourMovements[i], bs);
v(vert.x, vert.y, depth + z);
v(vert.x, vert.y, depth + z + offsetSize.z);
}

for (let h = 0, hl = holes.length; h < hl; h++) {
const ahole = holes[h];
oneHoleMovements = holesMovements[h];
for (let i = 0, il = ahole.length; i < il; i++) {
const vert = this.scalePoint2(ahole[i], oneHoleMovements[i], bs);
v(vert.x, vert.y, depth + z);
v(vert.x, vert.y, depth + z + offsetSize.z);
}
}
}
Expand Down Expand Up @@ -237,7 +291,7 @@ export class ExtrudeGeometry extends GeometryBase {
self.addGroup(start, verticesArray.length / 3 - start, 1);
}

function sidewalls(contour: Vector2[], layeroffset: number) {
function sidewalls(contour: Vector2[], layeroffset: number, isClockWise = false) {
let i = contour.length;
while (--i >= 0) {
const j = i;
Expand All @@ -252,7 +306,7 @@ export class ExtrudeGeometry extends GeometryBase {
c = layeroffset + k + slen2,
d = layeroffset + j + slen2;

f4(a, b, c, d);
f4(a, b, c, d, isClockWise);
}
}
}
Expand All @@ -263,10 +317,16 @@ export class ExtrudeGeometry extends GeometryBase {
placeholder.push(z);
}

function f3(a: number, b: number, c: number) {
addVertex(a);
addVertex(b);
addVertex(c);
function f3(a: number, b: number, c: number, isClockWise = false) {
if(isClockWise){
addVertex(a);
addVertex(b);
addVertex(c);
}else{
addVertex(a);
addVertex(c);
addVertex(b);
}

const nextIndex = verticesArray.length / 3;
const uvs = WorldUVGenerator.generateTopUV(verticesArray, nextIndex - 3, nextIndex - 2, nextIndex - 1);
Expand All @@ -276,14 +336,24 @@ export class ExtrudeGeometry extends GeometryBase {
addUV(uvs[2]);
}

function f4(a: number, b: number, c: number, d: number) {
addVertex(a);
addVertex(b);
addVertex(d);

addVertex(b);
addVertex(c);
addVertex(d);
function f4(a: number, b: number, c: number, d: number, isClockWise = false) {
if(isClockWise){
addVertex(a);
addVertex(b);
addVertex(d);

addVertex(b);
addVertex(c);
addVertex(d);
}else{
addVertex(a);
addVertex(d);
addVertex(b);

addVertex(b);
addVertex(d);
addVertex(c);
}

const nextIndex = verticesArray.length / 3;
const uvs = WorldUVGenerator.generateSideWallUV(verticesArray, nextIndex - 6, nextIndex - 3, nextIndex - 2, nextIndex - 1);
Expand Down
2 changes: 1 addition & 1 deletion packages/geometry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ export * from "./text/TextGeometry"
export * from "./terrain/TerrainGeometry"
export * from "./grass/GrassGeometry"
export * from "./grass/component/GrassComponent";
export * from "./grass/material/GrassMaterial";
export * from "./grass/material/GrassMaterial";
2 changes: 1 addition & 1 deletion packages/geometry/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orillusion/geometry",
"version": "0.2.4",
"version": "0.2.7",
"author": "Orillusion",
"description": "Orillusion Geometry Plugin",
"main": "./dist/geometry.umd.js",
Expand Down
1 change: 0 additions & 1 deletion packages/geometry/text/TextGeometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export class TextGeometry extends ExtrudeGeometry {
break;
}
}

if (shape2D) {
this.shapes.push(shape2D);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/graphic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@orillusion/graphic",
"version": "0.2.2",
"version": "0.2.4",
"author": "Orillusion",
"description": "Orillusion Graphic Plugin",
"main": "./dist/graphic.umd.js",
Expand Down
11 changes: 11 additions & 0 deletions packages/graphic/renderer/Graphic3DBatchRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ export class Graphic3DBatchRenderer extends RenderNode {
}
}

public clear(){
this.shapes.clear();
this.mDirtyData = true;
}

public nodeUpdate(view: View3D, passType: PassType, renderPassState: RendererPassState, clusterLightingBuffer?: ClusterLightingBuffer) {
if(this.isDestroyed)
return
if (this.mDirtyData) {
let offset = 0;
let posAttrData = this.geometry.getAttribute(VertexAttributeName.position);
Expand Down Expand Up @@ -139,4 +146,8 @@ export class Graphic3DBatchRenderer extends RenderNode {
this.mDirtyData = true;
return shape;
}

public destroy(force?: boolean): void {
super.destroy(force);
}
}
4 changes: 2 additions & 2 deletions packages/graphic/renderer/Graphic3DRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,8 @@ export class Graphic3D extends Object3D {
* Erase all drawn graphics
*/
public ClearAll() {
this.mLineRender.shapes.clear();
this.mFillRender.shapes.clear();
this.mLineRender.clear();
this.mFillRender.clear();
}

/**
Expand Down
Loading

0 comments on commit 8887427

Please sign in to comment.