Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 3 out of 19 pages
Exam (elaborations)

COS3712 ASSIGNMENT 2 SOLUTIONS 2021

Document preview thumbnail
Preview 3 out of 19 pages

COS3712 ASSIGNMENT 2 SOLUTIONS 2021

Content preview

COS3712 ASSIGNMENT 2 SOLUTIONS 2021

<!DOCTYPE html>



<html>



<head>

<title>COS3712 Assignment</title>

<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/three.js/87/three.min.js"></script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dat-
gui/0.7.2/dat.gui.min.js"></script>

<style>

body {

/* set margin to 0 and overflow to hidden, to go fullscreen */

margin: 0;

overflow: hidden;

}

</style>

</head>



<body>

<!-- Div which will hold the Output -->

<div id="WebGL-output"></div>



<!-- Javascript code that runs our Three.js examples -->

<script type="text/javascript">



// create a scene, that will hold all our elements such as objects, cameras and lights.

, var scene = new THREE.Scene();



// create a camera, which defines where we're looking at.

var camera = new THREE.PerspectiveCamera(55, window.innerWidth / window.innerHeight, 0.1,
1000);

camera.position.z = 500;



// create a render and set the size

var renderer = new THREE.WebGLRenderer();

renderer.setClearColor(new THREE.Color(0x00c9d0));

renderer.setSize(window.innerWidth, window.innerHeight);

document.body.appendChild(renderer.domElement);

renderer.shadowMapEnabled = true;



// create group

var group = new THREE.Object3D();

var globeMaterial = new THREE.MeshPhongMaterial({ color: 0xffff00, emissive: 'blue',
emissiveIntensity: 0 });

var truck_group = new THREE.Object3D();



THREE.crossOrigin = "";

//-----------------------------------create the ground-----------------------------------------------

var grass_texture = new THREE.TextureLoader().load( 'https://2.bp.blogspot.com/-
bT1mrSnNFg4/VR74ekEhgoI/AAAAAAAAHrI/0xTxxmku7Yo/s1600/Green%2Blush%2Bgrass%2Btextur
e.jpg' );

grass_texture.wrapS = THREE.RepeatWrapping;

grass_texture.wrapT = THREE.RepeatWrapping;

grass_texture.repeat.set( 8, 8 );

var planeGeometry = new THREE.PlaneGeometry(350, 300);

, var planeMaterial = new THREE.MeshLambertMaterial({ map: grass_texture});

var plane = new THREE.Mesh(planeGeometry, planeMaterial);

// rotate and position the plane

plane.rotation.x = -0.5 * Math.PI;

plane.position.x = 8.5;

plane.position.y = -12;

plane.position.z = -8;

// add the plane to the group

group.add(plane);

plane.castShadow = true;

plane.receiveShadow = true;




//---------------------------------------create truck---------------------------------------------------------

var road_group = new THREE.Object3D();

//road:

var road_texture = new THREE.TextureLoader().load( 'https://3.bp.blogspot.com/-RFCO_cQG-
mQ/UAwR3S46jlI/AAAAAAAAB4I/yvNzx2krbx4/s1600/Seamless+brick+texture+dark+00.jpg' );

road_texture.wrapS = THREE.RepeatWrapping;

road_texture.wrapT = THREE.RepeatWrapping;

road_texture.repeat.set( 10, 10 );

var road_geometry = new THREE.BoxGeometry( 350, 2, 60 );

var road_material = new THREE.MeshLambertMaterial({ map:road_texture});

var road = new THREE.Mesh( road_geometry, road_material );

road.position.y = -12.9;

road.position.x = 9;

road.position.z = 9;

Document information

Uploaded on
May 7, 2021
Number of pages
19
Written in
2020/2021
Type
Exam (elaborations)
Contains
Questions & answers
$19.38

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
hiltontutorials
3.7
(359)
Sold
1905
Followers
1219
Items
858
Last sold
11 months ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions