CS185c
Chris Pollett
Mar 6, 2019
brew cask install android-platform-tools
adb devicesand see a list of connected Android devices.
List of devices attached 1KWPH810RN8115 device
adb logcat
... 03-06 09:41:59.956 1322 1765 I ovrsensors: Setting sensor 2 sampling rate to 0.00, batch size=0 03-06 09:41:59.956 1322 1351 I GattConnection: onDisconnect - closing gatt 03-06 09:41:59.956 1322 1351 D BluetoothGatt: close() 03-06 09:41:59.956 1322 1351 D BluetoothGatt: unregisterApp() - mClientIf=5 03-06 09:41:59.956 1074 1109 D BtGatt.GattService: unregisterClient() - clientIf=5 ...
adb logcat -s chromium
03-06 09:46:52.175 4379 4379 I chromium: [INFO:CONSOLE(129)] "hi there!! presenting", source: https://www.cs.sjsu.edu/faculty/pollett/185c.1.19s/WebVR.html (129)
adb shell ip route 10.1.10.0/24 dev wlan0 proto kernel scope link src 10.1.10.37
adb tcpip 5555
adb connect 10.1.10.37
brew cask install vlc
adb exec-out "while true; do screenrecord --bit-rate=2m --output-format=h264 --time-limit 180 -; done" | vlc --demux h264 --h264-fps=60 --clock-jitter=0 -to do a screencast (above should all be on one line).
function car(new_make, new_model, new_year) { this.make = new_make; this.model = new_model; this.year = new_year; }
my_car = new car("Ford", "Contour SVT", "2000");
function display_car() { document.write("Make:", this.make, "<br />"); document.write("Model:", this.model, "<br />"); document.write("Year:", this.year, "<br />"); } function car(new_make, new_model, new_year) { //same as before this.display = display_car; } my_car = new car("Ford", "Contour SVT", "2000"); my_car.display();
function car(new_make, new_model, new_year) { //same as before } car.prototype.display = display_car;
function car(new_make, new_model, new_year) { //same as before car.prototype.display = function() { document.write("Make:", this.make, "<br />"); document.write("Model:", this.model, "<br />"); document.write("Year:", this.year, "<br />"); } }
function A() { } A.prototype.foo = function() { alert("foo"); } function B() { } B.prototype = new A(); /* we just made B's prototype an instance of an A function object which has its own prototype. So property look up for B, looks within its instance, then within it prototype, which is an instance of A, to see if it is a property of A, then it looks at A's prototype to see if the property is there. As A's prototype is an Object, it finally looks at Object's prototype to see if the property is there. */ B.prototype.goo = function() { alert("goo"); } a = new A(); a.foo(); // alert with foo in it b = new B(); b.foo(); // alert with foo in it b.goo(); // alert with goo in it a.goo(); // type error goo is not a function of A
var object_we_are_making = (function () { // private variables return { // public data and methods } }());
var employee = (function() { var salary = 20000; return { name: "John Smith", getSalary : function () { return salary; }, setSalary : function (sal) { salary = sal; } } }()); alert(employee.name); // John Smith alert(employee.getSalary()); // 20000 employee.setSalary(100000); alert(employee.getSalary()); // 100000 alert(employee.salary); // undefined
function Employee(name, sal) { var salary; // scope within constructor this.name = name; salary = sal; this.getSalary = function () { return salary; } this.setSalary = function (sal) { salary = sal; } } var emp1 = new Employee("John", 100000); var emp2 = new Employee("Sally", 150000); alert(emp1.name); // John alert(emp2.name); // Sally alert(emp1.getSalary()); // 100000 emp2.setSalary(200000); alert(emp2.getSalary()); // 200000 alert(emp1.getSalary()); // 100000 alert(emp1.salary); // undefined
class MyClass { contructor(arg1, arg2,...) { // code this.foo = arg1; //an example of setting a field } //getter methods... get myGetterFunction(arg1, ...) { // code } // a bunch or instance methods... myMethod1(arg1, ...) { // code } // a bunch or static methods... static myStaticMethod1(arg1, ...) { // code } }
class B extends A { //code //can refer to parent in child using super keyword. I.e., super.foo() }
//my_module.js function hideme() { return "from hideme"; } export function showme() { return showme(); } export class goo { } //another syntax for this is function foo1() { } function foo2() { } export {foo1, foo2}
<script type="module" src="my_module.js" >
<script type="module"> // some code </script>
<script type="module" src="my_module.js" > <script type="module" src="my_module.js" >would have the same effect as just a single copy of the above line.
var x = 3.14; // if this was the first occurence of xrather than the more lazy
x = 3.14;
//my_second_module.js import {showme} from "./my_module.js"; // I can now call showme() import "some_other_module.js" //executes module only for side-effects import * as ModuleName from "./module_name.js" //import everything with a name /* if module_name.js exports foo(), I could then use this function as ModuleName.foo(); */
function VRExperience() { this.vr_objects = []; this.then = 0; this.gl = null //... other initializations } VRExperience.prototype.init = function () { /* set up this.gl create all VR Objects use for scene add to this.vr_objects for each this.vr_objects element i this.vr_objects[i].init(this.gl) */ } VRExperience.prototype.start = function () { //used to start drawing scene window.requestAnimationFrame(this.render); } VRExperience.prototype.render = function (delta_time) { var now *= 0.001; // convert to seconds var delta_time = now - this.then; this.then = now; this.draw(delta_time); requestAnimationFrame(this.render); } VRExperience.prototype.update = function (delta_time) { /* code to update positions of all vr_objects using delta_time can have code which is a for loop over vr_objects array. and for each element in the array call its update(delta_time) */ } VRExperience.prototype.draw = function (delta_time) { /* for each eye for each element i in vr_objects this.vr_objects[i].draw(this.gl, current_view_matrix, current_projection_matrix_for_eye) */ }