You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 28, 2025. It is now read-only.
I want to build a file uploader (obj, mtl, etc.) but access files directly in the browser using the FileReader API instead of sending it to a server and retrieve it from there again with the <Asset src='..'> component.
Regarding functionally this is probably very similar to this project: https://3dviewer.net/#
Now... this seems to be a good starting point. I have a very simple MWE that writes the content of an uploaded obj file to a data variable objtext but I have no idea how to load this into the Scene.
Within a week, I made little progress. There is some action on the upload feature, but the obj files are not shown.
This is the updated code so far:
<template>
<div>
<inputid="files"type="file"multiple@change="reloadObjFiles">
<Scenev-model="myScene"@scene="onScene">
<HemisphericLightdiffuse="#F00"></HemisphericLight>
<Propertyname="clearColor"color="#fff" />
<Camerav-model="camera":radius="2500"type="arcRotate" />
</Scene>
</div>
</template>
<script>
exportdefault { name:'Upload',data () {return { myScene:null, myEntity:null, myBox:null, camera:null, objFile:null } }, watch: {myScene () {// myScene is now available from the component// do something with it here or call a method to use it from here } }, methods: {reloadObjFiles (event) {// vars// const scene = this.mySceneconsole.log(event.target.files)this.filesInput.loadFiles(event) },onScene (scene) {// should be fired when the scene object has been initializedvar babylon =this.BABYLONvar engine =scene.getEngine()// var canvas = engine.getRenderingCanvas()var filesInput =newbabylon.FilesInput(engine, null, scene, null, null, null, function () {babylon.Tools.ClearLogCache() }, null, null)filesInput.onProcessFileCallback=function (file, name, extension) {console.log('done: '+ (typeof file) +''+ name +''+ extension)returntrue }// global varsthis.filesInput= filesInputthis.myScene= scene } }}
</script>
I want to build a file uploader (obj, mtl, etc.) but access files directly in the browser using the FileReader API instead of sending it to a server and retrieve it from there again with the
<Asset src='..'>
component.Regarding functionally this is probably very similar to this project: https://3dviewer.net/#
Now... this seems to be a good starting point. I have a very simple MWE that writes the content of an uploaded obj file to a data variable
objtext
but I have no idea how to load this into theScene
.My filereader looks like:
The text was updated successfully, but these errors were encountered: