Historical building modeling #141

Open
opened 2026-06-10 08:30:52 +00:00 by utopiah · 1 comment
Owner

Inspired by #139 and part of #138

Inspired by #139 and part of #138
Author
Owner

Consider blocktable.js used for #91 adapting with specific set of primitives, e.g. gray cylinders, triangles, boxes

Note it exposed data = window.exportBlocksFromTable()

Unfortunately loading back means showing the interface that the blocktable component uses. Overall this highlights a pattern that could have a "headless" of interface-less mode for most component. This is typically done in init() but maybe it should not be done this way. At least there should be a way to hide or disable the interface after being added.

It's a very short code snippet used frequently so abstracted away and added to remixes.js

// e.g. let data = JSON.parse(decodeURI(window.location.hash.replace('#','') ))
function parseEntitiesFromURI( URI, anchoringEl = AFRAME.scenes[0] ){
	let data = JSON.parse(decodeURI(URI))
	const properties = ["position", "rotation", "color", "scale", "src" ]
	data.map( d => {
		let el = document.createElement( d.elementType )
		properties.map( p => { if (d[p]) el.setAttribute(p, d[p] ) })
		anchoringEl.appendChild(el)
	})
	return anchoringEl
}

which can be tested with

let hashValueExample = '[{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%220%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/box.glb%22},{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%221.1111111111111112%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/cone-flat.glb%22},{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%222.2222222222222223%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/cone.glb%22},{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%223.333333333333333%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/debris-bolt.glb%22},{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%224.444444444444445%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/debris-bumper.glb%22}]'

let parentEl = parseEntitiesFromURI( hashValueExample )

which can then be used as a 1-liner e.g. demonstrated in remix__load_entities_example.json testable via https://biggu.benetou.fr/remixed_room.html?room=onboarding&loadRemix=remix__load_entities_example.json

Consider `blocktable.js` used for #91 adapting with specific set of primitives, e.g. gray cylinders, triangles, boxes Note it exposed `data = window.exportBlocksFromTable()` Unfortunately loading back means showing the interface that the `blocktable` component uses. Overall this highlights a pattern that could have a "headless" of interface-less mode for most component. This is typically done in `init()` but maybe it should not be done this way. At least there should be a way to hide or disable the interface after being added. It's a very short code snippet used frequently so abstracted away and added to `remixes.js` ```javascript // e.g. let data = JSON.parse(decodeURI(window.location.hash.replace('#','') )) function parseEntitiesFromURI( URI, anchoringEl = AFRAME.scenes[0] ){ let data = JSON.parse(decodeURI(URI)) const properties = ["position", "rotation", "color", "scale", "src" ] data.map( d => { let el = document.createElement( d.elementType ) properties.map( p => { if (d[p]) el.setAttribute(p, d[p] ) }) anchoringEl.appendChild(el) }) return anchoringEl } ``` which can be tested with ``` let hashValueExample = '[{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%220%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/box.glb%22},{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%221.1111111111111112%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/cone-flat.glb%22},{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%222.2222222222222223%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/cone.glb%22},{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%223.333333333333333%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/debris-bolt.glb%22},{%22elementType%22:%22A-GLTF-MODEL%22,%22position%22:%224.444444444444445%200%200%22,%22scale%22:%221%201%201%22,%22rotation%22:{%22x%22:0,%22y%22:0,%22z%22:0},%22color%22:null,%22src%22:%22/asset-kits/kenney_car-kit/Models/GLB%20format/debris-bumper.glb%22}]' let parentEl = parseEntitiesFromURI( hashValueExample ) ``` which can then be used as a 1-liner e.g. demonstrated in `remix__load_entities_example.json` testable via https://biggu.benetou.fr/remixed_room.html?room=onboarding&loadRemix=remix__load_entities_example.json
Sign in to join this conversation.