Code Monkey home page Code Monkey logo

skinview3d's People

Contributors

dependabot[bot] avatar foliageowo avatar fossabot avatar g-plane avatar hacksore avatar james090500 avatar leaphant avatar mochaap avatar prinsss avatar rtm516 avatar so1ve avatar theandrey avatar yushijinhun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

skinview3d's Issues

How do i put it in a website

i'm new to html, and i have no idea how to put this in a website. Do i just paste in the whole folder? I dont really know what else i would do...

Head overlay render issue

The hat overlay area seems have rendering issues when viewed in certain angles. As you can see when my headphones render the underside of the headphone is see through. Some type of blending or culling issue possibly?

image

Erorr build =(

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]~prebuild: [email protected]
6 silly lifecycle [email protected]~prebuild: no script for prebuild, continuing
7 info lifecycle [email protected]~build: [email protected]
8 verbose lifecycle [email protected]~build: unsafe-perm in lifecycle true
9 verbose lifecycle [email protected]~build: PATH: /usr/share/npm/bin/node-gyp-bin:/mnt/i/GitHub/GAMAI_SERVER/skinview3d/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
10 verbose lifecycle [email protected]~build: CWD: /mnt/i/GitHub/GAMAI_SERVER/skinview3d
11 silly lifecycle [email protected]~build: Args: [ '-c', 'npm run build:modules && npm run build:bundles' ]
12 silly lifecycle [email protected]~build: Returned: code: 1  signal: null
13 info lifecycle [email protected]~build: Failed to exec build script
14 verbose stack Error: [email protected] build: `npm run build:modules && npm run build:bundles`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack     at emitTwo (events.js:126:13)
14 verbose stack     at EventEmitter.emit (events.js:214:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:126:13)
14 verbose stack     at ChildProcess.emit (events.js:214:7)
14 verbose stack     at maybeClose (internal/child_process.js:925:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
15 verbose pkgid [email protected]
16 verbose cwd /mnt/i/GitHub/GAMAI_SERVER/skinview3d
17 error Linux 4.4.0-19041-Microsoft
18 error argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
19 error node v8.10.0
20 error npm  v3.5.2
21 error code ELIFECYCLE
22 error [email protected] build: `npm run build:modules && npm run build:bundles`
22 error Exit status 1
23 error Failed at the [email protected] build script 'npm run build:modules && npm run build:bundles'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the skinview3d package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     npm run build:modules && npm run build:bundles
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs skinview3d
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls skinview3d
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Wings support

Hi! I've came up with idea to improve skinview3d. Many custom Minecraft clients added wings mod so it would be awesome to show them on the web like cape or elytra.

Here is Wings mod: https://www.curseforge.com/minecraft/mc-mods/wings
Here is Cosmetic Wings mod: http://www.9minecraft.net/cosmetic-wings-mod/
Here is for example Badlion Client Store where players can buy wings: https://store.badlion.net/
In Poland we have for example Blazingpack (https://blazingpack.pl/) where some players are awarded with wings.

2D example images (all contain 2 wings): https://imgur.com/a/vFXZ6eY
2D example image (contains 1 wing): https://imgur.com/a/wUdNy3o
Both of these versions should be supported.

Look Mouse Support

I needed a function where the skin would look at the mouse. I tried to do this by editing the code, but I couldn't :(

Package size is too large

At present, this module directly imports Three.js:

import * as THREE from 'three'

So the bundle files contains about 500kb of Three.js codes. It is too huge.

So you can reduce the bundling size by this ways:

  • Tree Shaking.
  • Import Three.js by this way:
import Vector2 from 'three/src/math/Vector2'

当前模块由于直接引入了 Three.js , 导致打包大小贼大 (大约 500kb ):

import * as THREE from 'three'

这些是一些解决方法:

  • 使用 Tree Shaking (首先得改文件里导入 Three.js 的写法, 最好用 bili 或者 rollup 弄个包含了 Tree Shaking 后的 Three.js 源码的模块)
  • 单独导入子模块:
import Vector2 from 'three/src/math/Vector2'

non-alpha skins hat layer

There needs to be a check for the hat layer before it's applied. Otherwise, it will draw the hat layer when we know that the skin did not intend for that.

Issue Example

Incorrect skin overlay on the model

When applying a normal skin to a slim model, incorrect overlay of pixels on the hands occurs.

viewer.detectModel = false;
viewer.playerObject.skin.slim = true;

image

Skin:
image

npm watch command for local development

Could we implement an npm script like this for real-time transpilation? This would also require an html file with the basic construct of the skin viewer.

Something like :
npm run watch

rollup -c tools/rollup.browser.min.js -w

We can discuss this more detail and figure out what works best. Currently, I have a local branch and it's working well to play around with the animation system.

Setting capeUrl to null should hide it

I ran into this issue and it's also noted here. When we set the cape to null it should automatically hide the cape, then when setting it again it will unhide it.

skinview3d/js/example.js

Lines 58 to 64 in b3858b5

// I've noted there is not a good way to set the cape to null
// so we hide it as work around but need to raise an issue
if (capeUrl === "") {
capeObject.visible = false;
} else {
skinViewer.capeUrl = capeUrl;
}

Not working in some browsers

Browsers that i tested and it's not working:

  • Edge

Error:
SCRIPT5009: SCRIPT5009: 'ImageBitmap' is not defined

missing method in interface

When using the module from npm I ran into the .add method not being found on IAnimation. Although this is not breaking anything in the codebase I do receive typescript errors as the method can't be found.

Issue

export interface IAnimation {
	play(player: PlayerObject, time: number): void;

	// this defintion is missing or is not being inherited correctly 
	add(animation: AnimationFn): AnimationHandle; 
}

https://github.com/to2mbn/skinview3d/blob/master/types/animation.d.ts#L4

Let me know what the issue is here or if I'm doing something wrong. For now I've manually edited the typings file but obviously, that is a hacky workaround.

Anti-aliasing

Currently models are very sharp, is it possible to add some kind of AA or SSAA?

Cape from link isn't working

If i upload cape normally it works, but if i'm trying to load it from link (ie. imgur (with .png added) it doesn't work

How can I make it to work properly?

(sorry for my english man)

preserve drawing buffer

When creating the instance of WebGLRenderer we should pass in preserveDrawingBuffer set to true which will make taking image captures of the canvas easier as well as rendering to a different canvas.

Add a way to execute a function on “Bad Cape Size”

Add something like skinViewer.capeTexture.onBadCapeSize or something similar. Since I want to be able to resize the cape texture if the cape size isn’t compatible. I want to be able to do something like skinViewer.capeTexture.onBadCapeSize = function() { something };

How to use this with webpack?

Hi,

How do I use this library with webpack?
I used npx creacte-next-app and I'm constantly getting this error

Error: Must use import to load ES Module node_modules/skinview3d/libs/skinview3d.js
require() of ES modules is not supported.
require() of node_modules/skinview3d/libs/skinview3d.js from /SSD/projects/auraside/mantle/mantle-ui/.next/server/static/development/pages/admin/capes.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename skinview3d.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /node_modules/skinview3d/package.json.

Code:

import * as skinview3d from 'skinview3d';
...
useEffect(() => {
  const skinViewer = new skinview3d.FXAASkinViewer({
    width,
    height,
    renderPaused: true,
  });
  },[])
...

Feat: pause rendering?

I want to pause rendering, but not dispose.

e.g.

const viewer = new Viewer(...)

// whem modal window close:
modal.on('off', () => viewer.pauseRender()) // or viewer.pauseDraw()

// open:
modal.on('open', () => viewer.continueRender()) // or viewer.draw()

But now, when I call viewer.dispose(), the instance is destroyed.

When I call viewer.disposed = false, it can't be restored from pausing.

I want to interrupt the execution of window.requestAnimationFrame() , but also can be restored.

Can you expose the draw method?

These two methods can also be named pauseDraw and draw.

Update gh-pages

Working on this now and am almost done. Do I have commit rights on this repo?

Discussion on the ownership transfer of the repository

The current owner of the repository is @to2mbn, an organization created by @Darkyoooooo and me years ago. The organization was aimed to gather Minecraft lovers in China and build things together.

But in fact it didn't go this way. I have discussed with @Darkyoooooo recently, and we are going to dissolve this organization. So we have to find a successor owner.

Currently, I feel like transfering the ownership to @bs-community. The organization is run by multiple persons. The Blessing Skin Server project, maintained by this organization, is also a major user of skinview3d. This is the reason why I choose it.

I'm leaving this issue open to collect comments about the ownership transfer. If there is no objection, I will perform the ownership transfer in July.

BTW, I'm coming back to the development this July, planning to add some wonderful features.

Add dist code to repo

Seems this is a common practice among other big repositories. More so in order to support this project on cdnjs I think we will need to do this.

See the related PR to track this effort on the cdnjs side cdnjs/packages#334

cors error

Code:

import { Skin } from './Skin';

<Skin skinUrl={`${config.cdnUrl}skins/steve.png`} capeUrl={`${config.cdnUrl}cloaks/steve.png`} />

Skin.tsx:

import * as SkinViewer from 'skinview3d';
import { useEffect, FC } from 'react';

interface IProps {
    skinUrl: string;
    capeUrl: string;
}

export const Skin: FC<IProps> = ({ skinUrl, capeUrl }) => {
    useEffect(() => {
        let viewer = new SkinViewer.SkinViewer({
            domElement: document.getElementById('skin_view'),
            width: 256,
            height: 256,
            skinUrl,
            capeUrl
        });
        
        let control = SkinViewer.createOrbitControls(viewer);
        control.enableRotate = true;
        control.enableZoom = false;
        control.enablePan = false;

        viewer.animation = new SkinViewer.CompositeAnimation() as any;
        (viewer.animation as any).add(SkinViewer.WalkingAnimation);
    });

    return (
        <div id='skin_view' />
    )
}

Getting this error:

Access to image at 'https://cdn.miforix.site/skins/steve.png' from origin 'http://localhost:5000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
GET https://cdn.miforix.site/skins/steve.png net::ERR_FAILED
Failed loading https://cdn.miforix.site/skins/steve.png

Migrate to using Yarn

Yarn is another JavaScript package manager which is faster than npm.
I'd like to migrate to Yarn but I still want to listen to any opinion, if someone disagree.

If everyone agree, this should be done after typescript branch merged.

Optimizing WebGL contexts

At the moment, when using a large number of skinview3d instances, we will get the error: Too many active WebGL contexts. Oldest context will be lost.
image

Is there a way to optimize the WebGL contexts on the library side?

Render image on nodejs server

I am working on a project, and would like to be able to send rendered images from this to clients.

I have tried to modify it to use three-software-renderer, rather than WebGLRenderer, and I cant see to get that to work.

Do you have any example code of this project being used server-side?

[feature] render in 2d

Hey. I want to show only the head of the skin. I made this code

const parts = viewer.playerObject.skin;
const invisible = ['body', 'leftArm', 'rightArm', 'leftLeg', 'rightLeg'];
            
for(const part of invisible) {
      parts[part].visible = false;
}

But it just hides other parts of the skin and the head does not get the entire area of the canvas.
I get this:
Снимок экрана 2020-01-05 в 22 29 51
Снимок экрана 2020-01-05 в 22 30 36

But i need something like this:
Снимок экрана 2020-01-05 в 22 45 03

Move to Typescript

I would love to see this project completely written in typescript. If I have time I can start working on a typescript branch.

It would make things a lot nicer not having to depend on type definition files. Furthermore, since I'm always writing typescript now it just feels more natural.

What is everyone else's thoughts on this?

Simplified programmatic access to body parts

This was a question asked by @johnrippus over on gitter.

Right now we don't have a way to access body part references easily. I'm working on a branch for this so that it would be possible to get the reference to a part via a lookup method.

However, this does require some more boilerplate code to manage all the parts.

image

@yushijinhun @g-plane What are your thoughts on this?

I cannot run the project

Would you please tell me the steps to run this project please?
I have done "npm install" and then I run "npm run build". Some errors happen.

src/skinview3d.ts → bundles/skinview3d.bundle.js...
[!] (plugin at position 1) TypeError: code.matchAll(...) is not a function or its return value is not iterable

I need some help ;(

HD cape

Hello, do you have plans about support hd capes?

Incorrect processing of semi-transparent layer

When using a skin with translucent parts on layer 2, on the model they look completely transparent

image
image

Skin: http://textures.minecraft.net/texture/f7058bfcbde8f50af98f7ca7ed02c6f72dfb4138ad9eff05bf264aa9e3ceca4f

new skinview3d.SkinViewer(el("skin_container"), {
		skin: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAilBMVEUAAACUkveZkveUkveSlfeSo/f+/fD+99n56cWn+Pr/yfH325Lw17eb8vXu07iS9Pfy0o3wzIr/sOuJ6/CO6O7oxK7qwIN93+jnuH991NyQwfKZtvhyzNaTrfaRrPWPqfNwv8n8f0lis7/3ekT1eEKtiorwcz3mZjWce4GMcnrbWSp3Y216XG5oWGSkm1OgAAAABnRSTlMAPFpzqtwj/aFFAAAEVklEQVR42q1WDXvjJgxm/gjqriHrMMdyR64LrNBzl///9/ZIAhsnTnNppzbGgHnRtyREpjSmlOgxjuOYkjinFIWIl8vzfooxRISg8+PlfsqPK0QM8PVE5/sxzs91DiJRGkdjjLkEuEkphnAMMY1GKaXMRwAyBwpAgrofYNKBIvogB2n8x5i3t7c3Y9bsxJrB/eUy2z8G1MA0LX4hJsvFL3+k6dD8i+gAEZ3gGNSY6JXWmCX8y+e/xvQ1FXYTreMjxBhCiCEGKUEmfA20hmOIIYWsohgTmoodISReD0kc8eoQAeRmIzcSgM15POaxOPqY2JEufJRvVHCSL6d/X+QJFHNUKLthEuKF/i/ChGUGpX6+vr6+/lQKik5QB5njGITg/SmgijZQiSmNyhh1+vP3E46kftIkDvmaymyTHvmRw8cU+xuen4d1Gtn+c5CQpfK21dZZa93sVKi0mHDdWW3LupQAoFa8UO+0c9b5ya299+hSeqet1Ttd1gEUKLMGQBzMAN57haLsNALo3cQBKAlrAHi4FsF5B4o4QBFmDlZFsHiLdd47hx/bccQ3KyFnp6IPCVIigMJwl4vbrSVlee+9swjgHWJQdiJDeJ/SKOVGyg0DbGoARRlIGSJMBKN31tmnv2yIyePl3jkfEzD/6CgKoAIABVDtQPJoOP3lSUdkCsPH2YjODtU9FQDLNgknSQ60nbYJzemPwblw9Fc5YNkKwEaiJhwpJuslBPrtif4m2u9rERB55gAiKROlouMYU0rFGAYihNjvh+GcA1l4kzLwuJFAAodjwCQdjlsihBiG7facA1COPEEBRNISLhkEjSEoSjLb7cN2+8AADzUA+rBjacmZSIfkWDRiyDmXot8OVzhAL8qORJHnrNaao5BHtIVLbthf0YF1k8ZZ+2jBHAMUjSOHNNarVTNWrKwt/nplclZ8juxnAf4HhHXqFwO/9/07+SBrxJVU3tHHfVcd6br+tkafhOCi1ODXfddUu+1tAKvFU/1137XVbvMrADutBdXRru36rmsXIvS3LTI7Ud+0bds2PecDXlrkg5tWaJvmt6bNl1IsPN9nxq5tmrbrOR/w2uFwBwDqoO/arsoHP74fljHgnCj5QLgcougTs9H7rqvywbfDe/ngQoR+fgrOB8/DRRgWB/xUPFSHXW4Yqrz5uJ5ElghzddY7jQVuKn8KzCPcwQLmwzmwhFAgDcg7RMDDHxChBHJO6ZqtU2om1VA4M1DP7QyZL5dDfz7PDQHVr80ZQNetcFD6BMWNgyllf6W9WQb53HDwAeDGQRVAbg/OAJoVgEnm3BS9w8Ey0S0BitASckOQ2wNRopqpv87B9MvFMLcHQuzr/uL5qg4kcyBB5XKc24P8Ec/W00LpE0rfkBsCzAbbh4ECsswP33+wH1AecMJWeQF7Te4bJg4G5qCeH76VGzknLPJCmU862Fc6yKIMz3UcYPBZK6Y+gRsH92jMI0kE663+fwoSvZEDBUlSAAAAAElFTkSuQmCC",
		width: el('width').value,
		height: el('height').value
	});

[feature request] modelType in constructor

This is a feature request for a way to set a skin's modelType directly from the SkinViewer constructor inside the SkinViewerOptions object.

who is requesting this feature and why:

me (Nate Stringham) I am a contributor to SkyCrypt and realized that solving SkyCryptWebsite/SkyCrypt#455 would be much easier if skinview3d allowed a model to be passed into the constructor

the problem that this feature would solve:

currently, it seems difficult to initialize a viewer with a model. the following code doesn't work because the auto-detect feature overrides modelType as soon as the skin is loaded.

skinViewer = new skinview3d.SkinViewer({
    skin: skin_data.skinurl,
    cape: skin_data.capeurl
});
skinViewer.playerObject.skin.modelType = skin_data.model;

the following code does work but requires an extra step and it would be nice if it could be done directly in the constructor

skinViewer = new skinview3d.SkinViewer({
    cape: skin_data.capeurl
});
skinViewer.loadSkin(skin_data.skinurl, skin_data.model);

why not just use the auto-detected model:

because some users use an incorrect model with their skin intentionally and we would like to respect that desition

what would this feature look like if added:

it would look something like this:

skinViewer = new skinview3d.SkinViewer({
    skin: skin_data.skinurl,
    cape: skin_data.capeurl,
    modelType: skin_data.model
});

Automation of code updating on skinview3d.com

I'd like to create a script to update the s3 bucket code for this demo on https://skinview3d.com/

Not sure where I should run this script but it should run at least once a week to check for newer versions of the skiview3d code. If it finds a new version it will download the source and compile then upload to s3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.