Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
agargaro committed Oct 17, 2024
1 parent a09a5ba commit 21ff809
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/objects/InstancedMesh2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import { InstancedRenderItem, InstancedRenderList } from "./InstancedRenderList.
// TODO: Add expand and count/maxCount when create?
// TODO: autoUpdate (send indexes data to gpu only if changes)
// TODO: getMorphAt to InstancedEntity
// TODO: sorting if CullingNone
// TODO: partial texture update
// TODO: matrix update optimized if changes only rot, pos or scale.
// TODO: visibility if not culling
// TODO: Use BVH only for raycasting
// TODO: composeMatrixInstance can be opt if only move or scale
// TODO: patchGeometry method
Expand Down Expand Up @@ -45,7 +43,7 @@ export class InstancedMesh2<
public instancesCount: number; // TODO handle update from dynamic to static
public bvh: InstancedMeshBVH;
public perObjectFrustumCulled = true;
public sortObjects = false; // TODO should this be true?
public sortObjects = false;
public customSort: (list: InstancedRenderItem[]) => void = null;
public raycastOnlyFrustum = false;
public visibilityArray: boolean[];
Expand Down Expand Up @@ -281,12 +279,12 @@ export class InstancedMesh2<

if (!setCallback) {
const texture = (this.material as ShaderMaterial).uniforms[name].value as DataTexture;
const size = texture.format === RedFormat ? 1 : (texture.format === RGFormat ? 2 : 4); // 3 is not supported
const array = texture.image.data;

if (size === 1) {
if (texture.format === RedFormat) {
setCallback = (id: number, value: UniformValue) => { array[id] = value as number };
} else {
const size = texture.format === RGFormat ? 2 : 4; // 3 is not supported
setCallback = (id: number, value: UniformValue) => { (value as UniformValueNoNumber).toArray(array, id * size) };
}

Expand Down
5 changes: 3 additions & 2 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "Node16",
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
"declaration": true,
Expand All @@ -13,6 +13,7 @@
"outDir": "build",
"esModuleInterop": true,
"noImplicitAny": false,
"skipLibCheck": true
},
"include": [
"src/**/*.ts"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"strict": true,
Expand Down

0 comments on commit 21ff809

Please sign in to comment.