Вам нужно будет исправить проблему кросс-происхождения для текстуры. Но примерно так и должно быть (также обратите внимание, что у вас не было источников света):
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 30, window.innerWidth/window.innerHeight, 0.1, 1000 );
// mouse controls
var controls = new THREE.OrbitControls( camera );
controls.autoRotate = true;
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
// load a texture, set wrap mode to repeat
var loader = new THREE.TextureLoader();
loader.crossOrigin = '';
var texture = loader.load( "http://packageonly.tk/1.jpg" );
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 4, 4 );
// add cube
var geometry = new THREE.BoxGeometry( 1, 1, 1 );
var material = new THREE.MeshPhongMaterial( {map:texture, specular: 0xFFFFFF,
shininess: 30,} );
var cube = new THREE.Mesh( geometry, material );
scene.add( cube );
let light1 = new THREE.PointLight(0xeeffee, 0.8);
light1.position.set(-5, 2, 2);
scene.add(light1);
let light2 = new THREE.PointLight(0xffeeff, 0.8);
light2.position.set(5, 2, -2);
scene.add(light2);
camera.position.z = 10;
var render = function () {
requestAnimationFrame( render );
controls.update();
renderer.render(scene, camera);
};
render();
<!DOCTYPE html>
<html>
<head>
<title>EX3</title>
<script src="http://packageOnly.tk/three.min.js"></script>
<script src="http://packageOnly.tk/OrbitControls.js"></script>
</head>
<body>
<!-- script src="js/js.js"></script -->
</body>
</html>
It's a classic build-versus-buy (or, in this case, download for free) decision isn't it?
How's your free time?
Five years, that's how long that little idea took. Plus 2 years of adding bells and whistles. And that, folks, is why I'm giving in and using a blog host. Because I have lots of ideas, lots of things to say and to explore, but only a few dozen years left at best. I can't afford to go chasing every 5-year idea that springs to mind. After due consideration of the crap web frameworks and crap blog packages out there, I decided that I don't want to spend my next 5 years implementing my vision for a decent self-publishing system. Someone else can do it.
http://steve-yegge.blogspot.com/2006/03/blog-or-get-off-pot.html
Rolling your own blog is a great project (and quite fun too!), but for practical usage, using something pre-made is going to be more secure, have more cool features, etc. etc. Unless you're incredibly dedicated, you'll probably end up cutting corners and end up with something that isn't quite what you want.
Despite being a Rails guy myself, I'm a huge fan of Wordpress. If you're looking for Rails-based blog engines, I've had luck with Mephisto, although the documentation leaves something to be desired. Radiant CMS is another CMS/Blog system that might be worth looking at.
If you are just looking for a project, then building your own blog engine is a good start.
Personally, though I have been a full-time Rails developer for the past 3 years, I still use and recommend Wordpress for myself and others.
A lot of Ruby/Rails developers have actually gone the route of using static website/blog generators. This has a few advantages. First, the pages are static HTML with no dependency on a database. This means they can be served by your front-end Web server (Apache, Nginx, etc.) faster than if they were to go through Mongrel, Thin or Phusion Passenger. Secondly, the pages will be easier for search engines to index. Finally, and probably most importantly, you can easily version control your posts using Git (or your favorite SCM)
I switched my blog over to a static model after development on Mephisto seemed to stall. I am using Tom Preston-Werner's Jekyll and Disqus for the comments. Works great. Give it a try!
In my next rails project I'm going to need blogging functionality. I'm wondering whether anyone has any good suggestions, or should I just role my own? (Probably not in 15 minutes)
I wouldn't recommend rolling your own blog system. You should look into using Radiant CMS with a blog extension.
I think the most important feature will be to display code samples elegantly.
For this I can recommend looking into SyntaxHighlighter.
If the project is to write a blog, don't roll your own. There are plenty solutions out there that will solve this problem for you while you worry about pumping out great content.
You will end up spending to much time futzing with the little things that don't really matter.
Все зависит от вашей цели:
Если это для целей обучения и для развлечения, закодируйте его с нуля. Кроме того, попробуйте добавить новую функциональность, которую вы не найдете в современных платформах для блогов. Например, сделайте так, чтобы разработчику было легко вести учебники или скринкасты для блогов.
Если это для клиента или просто для блога, используйте wordpress. Вы можете иметь свой сайт в рубине, а затем ссылку на WordPress. Подумайте об этом, сколько человеко-часов отстает от WordPress, чтобы вы могли сопоставить, что вам нужно будет работать над ним в течение 8 лет.
WordPress будет работать «из коробки», а затем вы можете периодически настраивать его, в зависимости от будущие потребности.
Я согласен, для развлечения и учебы, код с нуля. Но подумайте о том, чтобы кодировать то, что людям действительно нужно, а их еще нет. Инновации.
Существует так много отличных блоговых платформ, и некоторые (например, Wordpress) имеют активные сообщества разработчиков, пишущие сотни полезных и мощных плагинов. И это включает в себя отличную поддержку примеров кода.
Не нужно изобретать велосипед.