forked from phenom/healer-man
Release Healer Man 0.1.24
This commit is contained in:
1 parent
c4346751a9
commit
bac0da9300
118 files changed
+857
-289
No files matched your search
@@ -1,10 +1,7 @@
|
||||
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { RigidBody, TrimeshCollider } from "@react-three/rapier";
|
||||
import {
|
||||
AdditiveBlending,
|
||||
DoubleSide,
|
||||
Mesh,
|
||||
NormalBlending,
|
||||
type InstancedMesh,
|
||||
type Material,
|
||||
type Object3D,
|
||||
@@ -24,49 +21,13 @@ import {
|
||||
import { disposeObject3DResources } from "./threeResourceDisposal";
|
||||
import { instanceRepeatedStaticMeshes } from "./staticSceneInstancing";
|
||||
import { useGameGLTF } from "./useGameGLTF";
|
||||
import { prepareDungeonMaterial } from "./productionDungeonMaterials";
|
||||
import {
|
||||
DUNGEON_COLLISION_LOAD_BATCH_SIZE,
|
||||
DUNGEON_VISUAL_LOAD_BATCH_SIZE,
|
||||
advanceDungeonAssetCount,
|
||||
} from "./dungeonLoadSequencing";
|
||||
|
||||
function matchesRole(name: string, patterns: readonly string[], names: readonly string[]): boolean {
|
||||
const lower = name.toLowerCase();
|
||||
return names.some((candidate) => candidate.toLowerCase() === lower)
|
||||
|| patterns.some((pattern) => new RegExp(pattern, "i").test(name));
|
||||
}
|
||||
|
||||
function prepareMaterial(source: Material, roles: DungeonMaterialRoles): Material {
|
||||
const material = source.clone();
|
||||
const name = material.name;
|
||||
material.side = DoubleSide;
|
||||
|
||||
if (matchesRole(name, roles.cutoutPatterns, roles.cutoutNames)) {
|
||||
material.transparent = false;
|
||||
material.opacity = 1;
|
||||
material.alphaTest = 0.5;
|
||||
material.depthWrite = true;
|
||||
material.blending = NormalBlending;
|
||||
} else if (matchesRole(name, roles.additivePatterns, roles.additiveNames)) {
|
||||
material.transparent = true;
|
||||
material.depthWrite = false;
|
||||
material.blending = AdditiveBlending;
|
||||
} else if (matchesRole(name, roles.blendPatterns, roles.blendNames)) {
|
||||
material.transparent = true;
|
||||
material.depthWrite = false;
|
||||
material.blending = NormalBlending;
|
||||
} else {
|
||||
material.transparent = false;
|
||||
material.opacity = 1;
|
||||
material.alphaTest = 0;
|
||||
material.depthWrite = true;
|
||||
material.blending = NormalBlending;
|
||||
}
|
||||
|
||||
material.needsUpdate = true;
|
||||
return material;
|
||||
}
|
||||
|
||||
function prepareVisual(root: Object3D, roles: DungeonMaterialRoles): Object3D {
|
||||
const clone = root.clone(true);
|
||||
const clonedMaterials = new Map<string, Material>();
|
||||
@@ -77,7 +38,7 @@ function prepareVisual(root: Object3D, roles: DungeonMaterialRoles): Object3D {
|
||||
const prepared = sources.map((source) => {
|
||||
const cached = clonedMaterials.get(source.uuid);
|
||||
if (cached) return cached;
|
||||
const next = prepareMaterial(source, roles);
|
||||
const next = prepareDungeonMaterial(source, roles);
|
||||
clonedMaterials.set(source.uuid, next);
|
||||
return next;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user