Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript definition #64

Open
jppresents opened this issue Jan 31, 2015 · 8 comments
Open

typescript definition #64

jppresents opened this issue Jan 31, 2015 · 8 comments

Comments

@jppresents
Copy link

hi,

I am using typescript to create my game.
(Typescript compiles down to javascript and can use typescript definitions to use pure javascript libs such as three.js or the ShaderParticleEngine.)

For three.js there is a definition available at definitelyTyped on github (they gather definitions for libs that don't provide them themself).

I made a minimal ShaderParticle.d.ts definition file, which enables use of groups and emitters in typescript.

It's only a few lines, would you be interested to host it in this project?

(It's ok if you are not, I'll then look into getting it into definitelyTyped - but I have not yet looked into their policies regarding size of projects or how to get definitions there.)

If you would just like to include it, here is the file:
http://jppresents.net/static/files/ShaderParticles.d.ts

@squarefeet
Copy link
Owner

I think it's a good idea, and one that would sit well with a pull-req I got a while back (IIRC) about adding package support (AMD/require/browserify-kinda stuff).

Could you link me to the definitelyTyped entry for Three.js?

@jppresents
Copy link
Author

@squarefeet
Copy link
Owner

Nice one, cheers. I'll take a peek.

@squarefeet
Copy link
Owner

Ha, that's so foreign to me. If you're up for making a draft version of a definition for this lib, that would be super handy. I've not used TypeScript very much at all, so I'd be best deferring to you with regards to that.

@jppresents
Copy link
Author

The linked file above (http://jppresents.net/static/files/ShaderParticles.d.ts) is actually enough to get up and running with your lib in typescript.

This way typescript knows which classes ShaderParticles offers and what their functions and datatypes are.

Typescript to create group / emitter with this definition looks like this:

    this.particles= new SPE.Group({
        texture: THREE.ImageUtils.loadTexture('models/particle.png'),
        maxAge: 0.5
    });

    this.emitter = new SPE.Emitter({
        type: 'cube'
        ...
    });

I am not sure if or how browserify/require use typescript definitions.

To clarify: I think if you put the linked ShaderParticles.d.ts file into the repository then typescript-people can directly start using the lib, no more work required by you or me.

@jppresents
Copy link
Author

Okay, just noticed when continuing with my game:
all the properties of emitters (and possible groups) will need to be defined in the definition too.
(Just listed with their correct types.)

All the ones, that you are supposed to be able to change after the creation of the emitter. (So they can be accessed on the emitter object in typescript.)

If you tell me where in the repo the file is supposed to go, I will submit a pull request when I got it done. Phaser (another lib I like to use) has them simply in a directory called typescript. (Linked as an example: https://github.com/photonstorm/phaser/tree/master/typescript )

@squarefeet
Copy link
Owner

I'm so glad you're doing this - I'd be lost in documentation right about now ;)

A new subfolder on master's root would be great... thanks again for doing this.

@zynga-jpetersen
Copy link

The link above for the typescript file (http://jppresents.net/static/files/ShaderParticles.d.ts) doesnt work any more, any chance you've got it around any more and can submit a pull request?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants