Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
vue-3d-loader
Advanced tools
vueJS + threeJS 3d viewer component. support .dae/.fbx/.gltf/.glb/.obj/.ply/.stl/.json models, and support the same scene to import multiple different 3D models, support mtl materials and texture
vueJS + threeJS 3d viewer component.
support .dae/.fbx/.gltf/.glb/.obj/.ply/.stl/.json models, and support the same scene to import multiple different 3D models, support mtl materials and texture
demo gif
Vue3 please install 2.0.0 or later, vue2 please install 1.x.x version
npm i vue-3d-loader -S # npm install vue-3d-loader -save
or
yarn add vue-3d-loader
If use in global, insert code in entry file:
/* vue2 */
import vue3dLoader from "vue-3d-loader";
Vue.use(vue3dLoader);
/* vue3 */
import vue3dLoader from "vue-3d-loader";
createApp(App).use(vue3dLoader).mount("#app");
If non-global use, insert code in your vue files:
import { vue3dLoader } from "vue-3d-loader"; // The vue3dLoader in {...}
Use tags in your components<vue3dLoader></vue3dLoader>
<vue3dLoader
:height="200"
:showFps="true"
:filePath="['/fbx/1.fbx', '/obj/2.obj', '/gltf/3.gltf']"
:mtlPath="[null, '/obj/2.mtl', null]"
:backgroundColor="0xff00ff"
></vue3dLoader>
Prop | Type | Default | Value | Description |
---|---|---|---|---|
filePath | string | array | - |
|
File path, supports multiple files to be loaded together, note: If each file corresponds to a material, you need to set the material mtlPath as an array. The same is true for image textures, which need to be set to textureImage as an array |
mtlPath | string | array | - |
|
Material path, supports multiple materials to be loaded together, set this parameter to an array, you must set filePath to an array |
textureImage | string | array | - |
|
jpg/png texture, if is array, filePath must be set to an array |
width | number | parent element width | 100 | Scene width |
height | number | parent element height | 100 | Scene height |
position | object | - |
| Model position coordinates |
rotation | object | - |
| Model rotation coordinates |
cameraPosition | object | {x:0, y:0, z:0} |
| Camera position coordinates |
cameraRotation | object | {x:0, y:0, z:0} |
| Camera rotation coordinates |
scale | object | {x:1, y:1, z:1} |
| Model scale |
lights | array | [{ type: "AmbientLight", color: 0xaaaaaa, }, { type: "DirectionalLight", position: { x: 1, y: 1, z: 1 }, color: 0xffffff, intensity: 0.8, }] |
| Lights is array, type AmbientLight | DirectionalLight | PointLight | HemisphereLight |
backgroundColor | number | string | 0xffffff |
| Scene background color |
backgroundAlpha | number | 1 |
| Background transparency. value range 0-1 |
controlsOptions | object | - | - |
Control parameter OrbitControls Properties |
crossOrigin | string | anonymous | anonymous | use-credentials | Cross-domain configuration. |
requestHeader | object | anonymous |
| Set request header. |
outputEncoding | string | linear | linear or sRGB |
linear is LinearEncoding, sRGB is sRGBEncoding (sRGBEncoding can restore material color better). Renderer's output encoding WebGLRenderer OutputEncoding |
webGLRendererOptions | object | { antialias: true, alpha: true } | - |
WebGLRenderer options WebGLRenderer Parameters |
showFps | boolean | false | - |
Show stats infomation |
clearScene | boolean | false | - | Clear scene |
parallelLoad | boolean | false | - |
Enable/disable parallel load models (useful only for multi-model loading). Use this attribute, the process event will be unpredictable |
labels | array | - |
|
Add an image/text label and set image to display the image label. Set text to display text labels. Text styles can be set using textStyle. For examples, see the examples/add-label.vue file |
event | description |
---|---|
mousedown(event, intersects) | mouse down, intersect: currently intersecting objects |
mousemove(event, intersects) | mouse move, intersect: currently intersecting objects |
mouseup(event, intersects) | mouse up, intersect: currently intersecting objects |
click(event, intersects) | click, intersect: currently intersecting objects |
load | load model event |
process(event, fileIndex) | loading progress, fileIndex: the index of the currently loaded model |
error(event) | error event |
supports dae/fbx/gltf(glb)/obj/ply/stl models
<!-- fbx model -->
<vue3dLoader
filePath="models/collada/stormtrooper/stormtrooper.dae"
></vue3dLoader>
<!-- obj model -->
<vue3dLoader filePath="/obj/1.obj"></vue3dLoader>
<!-- Load multiple models of different type -->
<template>
<vue3dLoader
:filePath="filePath"
:scale="{ x: 0.4, y: 0.4, z: 0.4 }"
:cameraPosition="{ x: 100, y: 200, z: 30 }"
/>
</template>
<script setup lang="ts">
import { ref } from "vue";
const filePath = ref();
filePath.value = [
"/models/fbx/Samba Dancing.fbx",
"models/collada/pump/pump.dae",
];
</script>
<!-- obj and mtl material -->
<vue3dLoader filePath="/obj/1.obj" mtlPath="/obj/1.mtl"></vue3dLoader>
<!-- fbx and png texture -->
<vue3dLoader filePath="/fbx/1.fbx" textureImage="/fbx/1.png"></vue3dLoader>
<vue3dLoader
filePath="/fbx/1.fbx"
:backgroundAlpha="0.5"
backgroundColor="red"
></vue3dLoader>
<template>
<div class="controls">
<div class="buttons">
<!-- 禁止右键拖动 -->
<button @click="enablePan = !enablePan">
{{ enablePan ? "disable" : "enable" }} translation
</button>
<!-- 禁止缩放 -->
<button @click="enableZoom = !enableZoom">
{{ enableZoom ? "disable" : "enable" }} zoom
</button>
<!-- 禁止缩放 -->
<button @click="enableRotate = !enableRotate">
{{ enableRotate ? "disable" : "enable" }} rotation
</button>
</div>
<vue3dLoader
:filePath="'/models/collada/elf/elf.dae'"
:controlsOptions="{
enablePan,
enableZoom,
enableRotate,
}"
:cameraPosition="{ x: 0, y: -10, z: 13 }"
/>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
const enablePan = ref(true);
const enableZoom = ref(true);
const enableRotate = ref(true);
</script>
<template>
<vue3dLoader
:rotation="rotation"
@load="onLoad()"
filePath="/models/collada/elf/elf.dae"
/>
</template>
<script setup lang="ts">
import { ref } from "vue";
const rotation = ref();
rotation.value = {
x: -Math.PI / 2,
y: 0,
z: 0,
};
function onLoad() {
rotate();
}
function rotate() {
requestAnimationFrame(rotate);
rotation.value.z -= 0.01;
}
</script>
<template>
<vue3dLoader filePath="/models/ply/Lucy100k.ply" @mousemove="onMouseMove" />
</template>
<script setup lang="ts">
import { ref } from "vue";
const object = ref(null);
function onMouseMove(event: MouseEvent, intersected: any) {
if (object.value) {
(object.value as any).material.color.setStyle("#fff");
}
if (intersected) {
object.value = intersected.object;
(object.value as any).material.color.setStyle("#13ce66");
}
}
</script>
Click here to see more demo code
This plugin is inseparable from vue-3d-model
FAQs
vueJS + threeJS 3d viewer component.
The npm package vue-3d-loader receives a total of 755 weekly downloads. As such, vue-3d-loader popularity was classified as not popular.
We found that vue-3d-loader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.