mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-29 16:07:14 +00:00
feat(ugc): glitter flecks (LEGO-AnimUV) and milky satin in made models
Glitter colors (Materials.xml type glitter, glitter_colors 114,117) go into S21_Glitter_Model and, transparent, S21_GlitterAlpha_Model (shader_glitter, default 21, LEGO-AnimUV). Their shapes get box-projected UVs, an NiTexturingProperty with a stored 128 px mipmapped fleck texture (NiSourceTexture + NiPersistentSrcTextureRendererData, as the client's own env_ag_ocean-maelstrom.nif) and two NiTextureTransformControllers looping the base map's translation (glitter_size, glitter_density, glitter_speed). The shader lays the texture over the vertex color by its alpha and outputs the vertex alpha, so transparent glitter blends as S01_Alpha does. Satin colors (satin_colors, LEGO's opal colors) stay in S01_Alpha but get satin_opacity and are whitened by satin_whiten. NifFile reads the base map's scroll speed (uvScroll) from the controllers; the icon draws still flecks, the UGC 3D view and the LXFML viewers moving ones. stats.json counts the glitter groups. With shader_glitter 0 and no satin colors the files are the same bytes as before (tested). Also keeps glow_emissive for the icon (it was reset by the icon settings). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,12 +2,13 @@
|
||||
* A 3D view of a .nif the UGC server made, from /api/ugc/mesh/:id (the dashboard converts it with NifFile::Encode,
|
||||
* as it does the scenery's models), with wireframe and vertex color switches and triangle counts. The metal and glow
|
||||
* groups (the UGC server's shader settings; each mesh's "look" is its shader's eShaderLook bits) are drawn as metal
|
||||
* reflecting the view's environment and as unlit glow.
|
||||
* reflecting the view's environment and as unlit glow, the glitter groups with moving white flecks (their UVs and
|
||||
* uvScroll, as the game moves its fleck texture).
|
||||
*/
|
||||
import * as THREE from 'three';
|
||||
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
||||
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
|
||||
import { parseModel, mergeMeshes, linearColors, metalOf, SHADER_LOOK } from '/js/scenery-core.js';
|
||||
import { parseModel, mergeMeshes, linearColors, metalOf, addGlitter, SHADER_LOOK } from '/js/scenery-core.js';
|
||||
|
||||
export function createNifViewer(container) {
|
||||
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
||||
@@ -31,6 +32,7 @@ export function createNifViewer(container) {
|
||||
scene.add(root);
|
||||
|
||||
let parts = [];
|
||||
const clock = new THREE.Clock();
|
||||
let wireframe = false, vertexColors = true, disposed = false, framed = false;
|
||||
const grey = new THREE.Color(0xbbbbbb);
|
||||
|
||||
@@ -49,6 +51,8 @@ export function createNifViewer(container) {
|
||||
function loop() {
|
||||
if (disposed) return;
|
||||
controls.update();
|
||||
const seconds = clock.getElapsedTime();
|
||||
for (const part of parts) if (part.glitter) part.glitter.update(seconds);
|
||||
renderer.render(scene, camera);
|
||||
requestAnimationFrame(loop);
|
||||
}
|
||||
@@ -125,10 +129,16 @@ export function createNifViewer(container) {
|
||||
? new THREE.MeshBasicMaterial({ color: baseColor.clone(), vertexColors: hasColors })
|
||||
: new THREE.MeshStandardMaterial({ color: baseColor.clone(), vertexColors: hasColors, transparent: seeThrough,
|
||||
roughness: metal === 'polished' ? 0.18 : metal === 'brushed' ? 0.45 : 0.6, metalness: metal ? 1 : 0 });
|
||||
// Glitter: the fleck texture's UVs, one tile of it each, moving as the game moves it
|
||||
let glitter = null;
|
||||
if (look & SHADER_LOOK.GLITTER && mesh.uvs) {
|
||||
geometry.setAttribute('glitterUv', new THREE.BufferAttribute(mesh.uvs, 2));
|
||||
glitter = addGlitter(material, { coordinates: 'uv', scroll: mesh.uvScroll || [0, 0] });
|
||||
}
|
||||
const object = new THREE.Mesh(geometry, material);
|
||||
if (seeThrough) object.renderOrder = 1;
|
||||
root.add(object);
|
||||
parts.push({ mesh: object, hasColors, baseColor });
|
||||
parts.push({ mesh: object, hasColors, baseColor, glitter });
|
||||
triangles += mesh.indices.length / 3;
|
||||
vertices += mesh.vertices;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user