|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
stories: ['../examples/stories/**/*.stories.js'],
|
||||
addons: ['@storybook/addon-knobs/register']
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"type": "commonjs"
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>skinview3d</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Archivo+Black" rel="stylesheet">
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #1e1e1e;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="skin_container"></div>
|
||||
|
||||
<script type="text/javascript" src="../bundles/skinview3d.bundle.js"></script>
|
||||
|
||||
<script>
|
||||
let skinViewer = new skinview3d.SkinViewer(document.getElementById("skin_container"), {
|
||||
width: 400,
|
||||
height: 300,
|
||||
skin: "./1_8_texturemap_redux.png"
|
||||
});
|
||||
|
||||
let control = new skinview3d.createOrbitControls(skinViewer);
|
||||
skinViewer.animations.add(skinview3d.WalkingAnimation);
|
||||
skinViewer.animations.speed = 1.5;
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,100 @@
|
|||
/* eslint-disable */
|
||||
import * as skinview3d from "../..";
|
||||
import { withKnobs, radios, number } from "@storybook/addon-knobs";
|
||||
|
||||
export default {
|
||||
title: "Skinview3d",
|
||||
decorators: [withKnobs],
|
||||
};
|
||||
|
||||
let currentAnimation;
|
||||
|
||||
const createViewer = () => {
|
||||
const element = document.createElement("div");
|
||||
const viewer = new skinview3d.SkinViewer(element, {
|
||||
width: 300,
|
||||
height: 400,
|
||||
skin: "textures/1_8_texturemap_redux.png",
|
||||
});
|
||||
|
||||
console.log(viewer);
|
||||
|
||||
// Control objects with your mouse!
|
||||
const control = skinview3d.createOrbitControls(viewer);
|
||||
control.enableRotate = true;
|
||||
control.enableZoom = false;
|
||||
control.enablePan = false;
|
||||
|
||||
// Add an animation
|
||||
currentAnimation = viewer.animations.add(skinview3d.WalkingAnimation);
|
||||
|
||||
return { viewer, element };
|
||||
};
|
||||
|
||||
let { viewer, element } = createViewer();
|
||||
|
||||
export const Basic = () => {
|
||||
// reset
|
||||
let { viewer, element } = createViewer();
|
||||
if (currentAnimation) {
|
||||
currentAnimation.remove();
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
export const Animation = () => {
|
||||
if (currentAnimation) {
|
||||
currentAnimation.remove();
|
||||
}
|
||||
|
||||
const animationMap = {
|
||||
Walk: skinview3d.WalkingAnimation,
|
||||
Run: skinview3d.RunningAnimation,
|
||||
Rotate: skinview3d.RotatingAnimation,
|
||||
};
|
||||
|
||||
const animationKey = radios("Animations", Object.keys(animationMap), "Run");
|
||||
currentAnimation = viewer.animations.add(animationMap[animationKey]);
|
||||
|
||||
const label = "Speed";
|
||||
|
||||
const defaultValue = 0.5;
|
||||
const options = {
|
||||
range: true,
|
||||
min: 0.1,
|
||||
max: 2,
|
||||
step: 0.01,
|
||||
};
|
||||
const value = number(label, defaultValue, options);
|
||||
|
||||
currentAnimation.speed = value;
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
export const Textures = () => {
|
||||
const skinOptions = {
|
||||
"1.8 Skin": "1_8_texturemap_redux",
|
||||
"Classic Skin": "Hacksore",
|
||||
"HD Skin": "ironman_hd",
|
||||
};
|
||||
const skinUrl = radios("Skin Textures", skinOptions, "1_8_texturemap_redux");
|
||||
|
||||
const capeOptions = {
|
||||
None: "none",
|
||||
"Classic Cape": "cape",
|
||||
"HD Cape": "hd_cape",
|
||||
};
|
||||
|
||||
const capeUrl = radios("Cape Textures", capeOptions, "none");
|
||||
viewer.loadSkin(`textures/${skinUrl}.png`);
|
||||
|
||||
if (capeUrl === "none") {
|
||||
viewer.loadCape(null);
|
||||
} else {
|
||||
viewer.loadCape(`textures/${capeUrl}.png`);
|
||||
}
|
||||
|
||||
return element;
|
||||
};
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 689 B |
|
@ -0,0 +1,3 @@
|
|||
# Example textures
|
||||
Assets in this directory are copyrighted by their original author(s), and are **OUTSIDE** the scope of skinview3d's license.
|
||||
These files are intended for demo use. If you are the copyright owner and disagree with our use, please submit an issue and we will remove the related files.
|
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 278 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.4 KiB |
13
package.json
|
@ -11,10 +11,10 @@
|
|||
"build": "npm run build:modules && npm run build:bundles",
|
||||
"test:lint": "eslint --ext .ts src",
|
||||
"test": "npm run test:lint",
|
||||
"dev:watch:modules": "tsc -w --declaration --sourceMap --outDir libs -p .",
|
||||
"dev:watch:bundles": "rollup -w -c",
|
||||
"dev:serve": "ws",
|
||||
"dev": "npm-run-all --parallel dev:watch:modules dev:watch:bundles dev:serve",
|
||||
"dev:watch:modules": "tsc -w --preserveWatchOutput --declaration --sourceMap --outDir libs -p .",
|
||||
"dev:watch:bundles": "rollup -w --no-watch.clearScreen -c",
|
||||
"dev:storybook": "start-storybook -s ./examples -p 6006",
|
||||
"dev": "npm-run-all --parallel dev:watch:modules dev:storybook",
|
||||
"prepublishOnly": "npm run clean && npm run build"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -42,13 +42,16 @@
|
|||
"three": "^0.117.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/addon-knobs": "^5.3.19",
|
||||
"@babel/core": "^7.10.4",
|
||||
"@rollup/plugin-node-resolve": "^8.1.0",
|
||||
"@rollup/plugin-typescript": "^5.0.0",
|
||||
"@storybook/html": "^5.3.19",
|
||||
"@typescript-eslint/eslint-plugin": "^3.4.0",
|
||||
"@typescript-eslint/parser": "^3.4.0",
|
||||
"@yushijinhun/three-minifier-rollup": "^0.1.7",
|
||||
"babel-loader": "^8.1.0",
|
||||
"eslint": "^7.3.1",
|
||||
"local-web-server": "^4.2.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.18.0",
|
||||
|
|