This file contains hidden or 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
Q:如何显示2d的sprite?一种呈现在场景中(如粒子),一种固定在屏幕上不动(如GUI/HUD) | |
A:不同点在于是否需要设置useScreenCoordinates为true。 | |
Q:如何按一定规则贴上纹理? | |
A:常用 texture.wrapS = texture.wrapT = THREE.RepeatWrapping; | |
texture.repeat.set( 10, 10 ); | |
var material = new THREE.MeshBasicMaterial( { map: texture, side: THREE.DoubleSide } ); |
This file contains hidden or 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
// 后台进程(优先级最低) | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ | |
}); | |
// 更新界面(优先级最高) | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
}); |
This file contains hidden or 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
scene = new THREE.Scene(); | |
scene.fog = new THREE.FogExp2( 0xcccccc, 0.002 ); |
This file contains hidden or 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
document.addEventListener("onmyevent", function(event){ | |
alert(event.eventType); | |
}, false); | |
var obj = document.getElementById("obj"); | |
var event = document.createEvent('HTMLEvents'); | |
event.initEvent("onmyevent", true, true); | |
event.eventType = 'message'; | |
document.dispatchEvent(event); |
This file contains hidden or 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
renderer.domElement.addEventListener( 'mousedown', handleMouseDown, false ); | |
function handleMouseDown(event) { | |
event.preventDefault(); | |
var mouseX =((event.clientX - container.offsetLeft )/ container.clientWidth )*2-1; | |
var mouseY =-((event.clientY - container.offsetTop )/ container.clientHeight )*2+1; | |
This file contains hidden or 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
D = d*W/w; | |
d = (w/2)/tan(fov/2); | |
===> | |
D = (W/2)/tan(fov/2); | |
(D: the distance between camera and 3d-objects | |
d: the distance between camera and screen | |
W: 3d-objects size | |
w: screen size) |
This file contains hidden or 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
{ | |
var texture = new THREE.ImageUtils.loadTexture( 'images/img.jpg' ); | |
texture.needsUpdate = true; | |
var material = new THREE.SpriteMaterial({ | |
map: texture, | |
useScreenCoordinates: false, | |
alignment: THREE.SpriteAlignment.center, | |
transparent: true | |
}); |
This file contains hidden or 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
UIColor *textDefaultColor = [UIColor blackColor]; | |
CGColorRef textDefaultColorRef = textDefaultColor.CGColor; | |
NSString *textDefaultColorStr = [CIColor colorWithCGColor:textDefaultColorRef].stringRepresentation; | |
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; | |
[userDefaults setObject:textDefaultColorStr forKey:@"textColorKey"]; |
This file contains hidden or 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
aBook = [[Book alloc] initWithBookNO:@"NO.21342413" bookName:@"清朝秘史" author:@"张家州" price:25.50]; | |
[aBook addObserver:self forKeyPath:@"price" options:NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew context:nil]; | |
// 观察到变化(收到来自被观察者的消息通知) | |
- (void)observeValueForKeyPath:(NSString *)keyPath | |
ofObject:(id)object | |
change:(NSDictionary *)change | |
context:(void *)context | |
{ | |
if([keyPath isEqual:@"price"]) { |
This file contains hidden or 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
options (如NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew)与infos的NSDictionary匹配使用 [infos objectForKey:@"old"], [infos objectForKey:@"new"] |