1
0
vrm/docs/wiki.md
2024-03-21 15:21:57 +09:00

3.0 KiB

example three-vrm

./dist/vrma

load("/vrma/model.vrm");
load("/vrma/VRMA_01.vrma");	

iframe

<div class="vrm-model">
<iframe src="https://vrm.syui.ai" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen scrolling="no"></iframe>
</div>

<style>
.vrm-model iframe {
	margin:30px 0 30px 0;
	width: 100%;
	height: 640px;
}
</style>

head

let head = currentVrm.humanoid.getRawBoneNode("head");
currentVrm.expressionManager.setValue('blink', 0);

bloom

//import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer';
//import { UnrealBloomPass } from 'three/examples/jsm/postprocessing/UnrealBloomPass';
//import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass";
// https://github.com/pmndrs/postprocessing
import { BloomEffect, EffectComposer, EffectPass, RenderPass } from "postprocessing";

const composer = new EffectComposer(renderer);
composer.addPass(new RenderPass(scene, camera));
composer.addPass(new EffectPass(camera, new BloomEffect()));

requestAnimationFrame(function render() {

	requestAnimationFrame(render);
	composer.render();

});

progress

// https://sbcode.net/threejs/progress-indicator
let manager = new THREE.LoadingManager();
let progressBar = document.getElementById('progressBar') as HTMLProgressElement

// https://threejs.org/docs/#api/en/loaders/managers/LoadingManager
manager.onStart = function ( url, itemsLoaded, itemsTotal ) {
    //console.log( 'Started loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' );
    progressBar.style.display = 'block'
        let percentComplete = (itemsLoaded / itemsTotal) * 100
        progressBar.value = percentComplete === Infinity ? 100 : percentComplete
};
manager.onLoad = function ( ) {
    //console.log( 'Loading complete!');
    progressBar.style.display = 'none'
};
manager.onProgress = function ( url, itemsLoaded, itemsTotal ) {
    let percentComplete = (itemsLoaded / itemsTotal) * 100
        progressBar.value = percentComplete === Infinity ? 100 : percentComplete
        //console.log( 'Loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' );
};
manager.onError = function ( url ) {
    //console.log( 'There was an error loading ' + url );
    progressBar.style.display = 'block'
};
<progress value="0" max="100" id="progressBar"></progress>
progress {
	width: 100%;
	height:8px;
	position: absolute;
	border-radius: 0px;
}

::-webkit-progress-bar {
	border-radius: 0px;
	background-color: #e6e6fa;
}

::-webkit-progress-value {
  background-color: #4682b4;
}