Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
110 lines (93 sloc)
4.23 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
body, html { | |
overflow-x: hidden; | |
overflow-y: hidden; | |
} | |
body { | |
margin: 0; | |
} | |
canvas { | |
width: 100%; | |
height: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<a href="https://github.com/InventivetalentDev/MineRender/blob/master/test/structure.html" target="_blank" style="position: absolute;"><img width="149" height="149" src="https://github.blog/wp-content/uploads/2008/12/forkme_left_gray_6d6d6d.png?resize=149%2C149" class="attachment-full size-full" alt="Fork me on GitHub" data-recalc-dims="1"></a> | |
<div style="position: fixed; right:10px; top:10px; background-color:lightgray; opacity: 50;z-index:10;font-family: 'Courier New',monospace;"> | |
<div id="targetInfo" style="margin: 5px;"> | |
</div> | |
</div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/96/three.min.js" ></script> | |
<script src="../dist/model.js"></script> | |
<script> | |
(function () { | |
window.modelRender = new ModelRender({ | |
showAxes: true, | |
showGrid: true,///TODO: fix block scale | |
showOutlines: true, | |
centerCubes: true, | |
mergeModels: true, | |
enableStats: true, | |
frameRateLimit: 60, | |
camera: { | |
type: "perspective", | |
x: 374.63961340330906, y: 302.33958985040925, z: 466.85165449163, | |
target: [0, 0, 0] | |
} | |
}) | |
// let raycaster = new THREE.Raycaster(); | |
let mouse = new THREE.Vector2(); | |
function onMouseMove(event) { | |
mouse.x = (event.clientX / modelRender.element.offsetWidth) * 2 - 1; | |
mouse.y = -(event.clientY / modelRender.element.offsetHeight) * 2 + 1; | |
} | |
window.addEventListener('mousemove', onMouseMove, false); | |
// document.body.addEventListener("modelRender", function () { | |
// $("#targetInfo").empty(); | |
// | |
// raycaster.setFromCamera(mouse, modelRender._camera); | |
// | |
// // calculate objects intersecting the picking ray | |
// let intersects = raycaster.intersectObjects(modelRender._scene.children, true); | |
// | |
// for (let i = 0; i < intersects.length; i++) { | |
// | |
// if(i===0) { | |
// $("#targetInfo").append(intersects[i].object.name + "<br/>") | |
// }else{ | |
// $("#targetInfo").append("<span style='color:gray'>"+intersects[i].object.name + "</span><br/>") | |
// } | |
// | |
// } | |
// }); | |
let urlBase = "https://assets.mcasset.cloud/1.15.2/data/minecraft/structures/"; | |
let url = urlBase+ "pillager_outpost/watchtower.nbt"; | |
if (location.hash.length > 4) { | |
url = urlBase + location.hash.substring(1)+".nbt"; | |
} | |
let modelConverter = new ModelConverter(); | |
modelConverter.structureToModels({ | |
url:url | |
},function (models) { | |
console.log(models) | |
modelRender.render(models,function () { | |
console.log("rendered!") | |
}) | |
}); | |
// modelConverter.schematicToModels({ | |
// url:"../res/ModernHouse.schematic" | |
// },function (models) { | |
// console.log(models); | |
// modelRender.render(models,function () { | |
// console.log("rendered!") | |
// }) | |
// }) | |
})(); | |
</script> | |
</body> | |
</html> |