mirror of
https://github.com/DarkflameUniverse/NexusDashboard.git
synced 2026-09-25 14:33:45 +00:00
fix: place player-built models using their stored position and rotation
DarkflameServer now normalizes UGC model LXFML around the model's own origin and stores the model's world position and rotation in properties_contents, the same as for prebuilt models. The property viewer only applied that transform to prebuilt models, so every player-built model rendered piled up at the origin. Pass each UGC model's stored position and rotation to the LDD converter and apply it to every brick (including flex parts) when building the scene. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -277,7 +277,9 @@
|
|||||||
this.xmldata = ''
|
this.xmldata = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
AddScene(file){
|
// placement: optional THREE.Matrix4 that places this model in the property. DLU stores player-built
|
||||||
|
// (UGC) models normalized around their own origin, with the position and rotation in properties_contents.
|
||||||
|
AddScene(file, placement = null){
|
||||||
let lxfmlfile = new DBURLFile(file,file)
|
let lxfmlfile = new DBURLFile(file,file)
|
||||||
this.xmldata = lxfmlfile.read()
|
this.xmldata = lxfmlfile.read()
|
||||||
|
|
||||||
@@ -305,7 +307,9 @@
|
|||||||
for (let j = 0; j < childnodes.length ;j++) {
|
for (let j = 0; j < childnodes.length ;j++) {
|
||||||
let childnode = childnodes[j]
|
let childnode = childnodes[j]
|
||||||
if (childnode.nodeName == 'Brick'){
|
if (childnode.nodeName == 'Brick'){
|
||||||
this.Bricks.push(new Brick(childnode))
|
let brick = new Brick(childnode)
|
||||||
|
brick.placement = placement
|
||||||
|
this.Bricks.push(brick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -531,9 +535,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadScene(filename){
|
LoadScene(filename, placement = null){
|
||||||
if(this.database.initok){
|
if(this.database.initok){
|
||||||
this.scene.AddScene(filename)
|
this.scene.AddScene(filename, placement)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,6 +612,11 @@
|
|||||||
n14, n24 ,n34, n44);
|
n14, n24 ,n34, n44);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move the brick from model space to its place on the property
|
||||||
|
if (bri.placement){
|
||||||
|
m.premultiply(bri.placement)
|
||||||
|
}
|
||||||
|
|
||||||
let decoCount = 0
|
let decoCount = 0
|
||||||
|
|
||||||
for (const [partindex, part] of geo.Parts.entries()){
|
for (const [partindex, part] of geo.Parts.entries()){
|
||||||
@@ -1033,10 +1042,14 @@
|
|||||||
|
|
||||||
|
|
||||||
//Start
|
//Start
|
||||||
|
// Player-built models with the position and rotation stored for them in properties_contents
|
||||||
let lxfml_file_list = [
|
let lxfml_file_list = [
|
||||||
{% for model in content %}
|
{% for model in content %}
|
||||||
{% if model.lot == 14 %}
|
{% if model.lot == 14 %}
|
||||||
"{{url_for('properties.get_model', id=model.id, file_format='lxfml', lod=lod)}}"{{ ", " if not loop.last else "" }}
|
{
|
||||||
|
"url": "{{url_for('properties.get_model', id=model.id, file_format='lxfml', lod=lod)}}",
|
||||||
|
"pos": {{ model.pos[0]|tojson }}
|
||||||
|
}{{ ", " if not loop.last else "" }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
]
|
]
|
||||||
@@ -1047,7 +1060,13 @@
|
|||||||
let converter = new Converter()
|
let converter = new Converter()
|
||||||
converter.LoadDBURL(ldddburl)
|
converter.LoadDBURL(ldddburl)
|
||||||
for (let i = 0; i < lxfml_file_list.length; i++) {
|
for (let i = 0; i < lxfml_file_list.length; i++) {
|
||||||
converter.LoadScene(lxfml_file_list[i])
|
let pos = lxfml_file_list[i].pos
|
||||||
|
let placement = new THREE.Matrix4().compose(
|
||||||
|
new THREE.Vector3(pos.x, pos.y, pos.z),
|
||||||
|
new THREE.Quaternion(pos.rx, pos.ry, pos.rz, pos.rw),
|
||||||
|
new THREE.Vector3(1, 1, 1)
|
||||||
|
)
|
||||||
|
converter.LoadScene(lxfml_file_list[i].url, placement)
|
||||||
}
|
}
|
||||||
converter.Export('test.webgl')
|
converter.Export('test.webgl')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user