-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11322 from stuikomma/setBlending_parameters_in_Sp…
…ritePlugin pass all blending parameters to setBlending in SpritePlugin
- Loading branch information
Showing
4 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>three.js webgl - sprites - premultiplied alpha</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> | ||
<style> | ||
body { | ||
padding:0; | ||
margin:0; | ||
font-weight: bold; | ||
overflow:hidden; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
|
||
<div id="info"> | ||
<a href="http://threejs.org" target="_blank">three.js</a> - webgl sprites alpha example - | ||
left is without premultiplied alpha, right is with premultiplied alpha | ||
</div> | ||
|
||
<script src="../build/three.js"></script> | ||
|
||
<script> | ||
|
||
var camera, scene, renderer; | ||
|
||
init(); | ||
animate(); | ||
|
||
function init() { | ||
|
||
var width = window.innerWidth; | ||
var height = window.innerHeight; | ||
|
||
camera = new THREE.PerspectiveCamera( 60, width / height, 1, 1000 ); | ||
camera.position.z = 100; | ||
|
||
scene = new THREE.Scene(); | ||
|
||
// create sprites | ||
var textureLoader = new THREE.TextureLoader(); | ||
var spriteTexture = textureLoader.load( "textures/sprite3.png" ); | ||
var spriteTexturePremultiplied = textureLoader.load( "textures/sprite3.png" ); | ||
spriteTexturePremultiplied.premultiplyAlpha = true; | ||
|
||
var materialPremultiplied = new THREE.SpriteMaterial( { | ||
map: spriteTexturePremultiplied, | ||
premultipliedAlpha: true | ||
} ); | ||
var spritePremultiplied = new THREE.Sprite( materialPremultiplied ); | ||
spritePremultiplied.scale.set( 40, 40, 40 ); | ||
spritePremultiplied.position.set( 20, 0, 0 ); | ||
scene.add( spritePremultiplied ); | ||
|
||
var materialNonPremultiplied = new THREE.SpriteMaterial( { map: spriteTexture } ); | ||
var spriteNonPremultiplied = new THREE.Sprite( materialNonPremultiplied ); | ||
spriteNonPremultiplied.scale.set( 40, 40, 40 ); | ||
spriteNonPremultiplied.position.set( -20, 0, 0 ); | ||
scene.add( spriteNonPremultiplied ); | ||
|
||
// renderer | ||
|
||
renderer = new THREE.WebGLRenderer(); | ||
renderer.setPixelRatio( window.devicePixelRatio ); | ||
renderer.setSize( window.innerWidth, window.innerHeight ); | ||
renderer.setClearColor( new THREE.Color( 'white' ) ); | ||
|
||
document.body.appendChild( renderer.domElement ); | ||
|
||
// | ||
|
||
window.addEventListener( 'resize', onWindowResize, false ); | ||
|
||
} | ||
|
||
function onWindowResize() { | ||
|
||
var width = window.innerWidth; | ||
var height = window.innerHeight; | ||
|
||
camera.aspect = width / height; | ||
camera.updateProjectionMatrix(); | ||
|
||
renderer.setSize( window.innerWidth, window.innerHeight ); | ||
|
||
} | ||
|
||
function animate() { | ||
|
||
requestAnimationFrame( animate ); | ||
render(); | ||
|
||
} | ||
|
||
function render() { | ||
|
||
renderer.render( scene, camera ); | ||
|
||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters