From 2d041a855fdae8af1b91034cf7a28ef9d24fce31 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Sat, 1 May 2021 22:16:30 -0700 Subject: [PATCH] Use https, Automate image creation --- scripts/install.sh | 70 +- scripts/new-image | 38 + scripts/rc.local | 20 +- scripts/setup.sh | 125 +++ scripts/setup_rpi.sh | 101 --- scripts/smb.conf | 30 + scripts/write-image | 14 + scripts/xinitrc | 11 +- src/avr/src/usart.c | 1 - src/bbserial/.gitignore | 2 + src/bbserial/Makefile | 8 +- src/bbserial/bbserial.c | 2 +- src/bbserial/yylloc.patch | 12 + src/boot/src/sp_driver.S | 2 +- src/boot/src/sp_driver.h | 2 +- src/jig/src/usart.c | 1 - src/js/orbit.js | 1292 +++++++++++++++--------------- src/pug/templates/docs-gcode.pug | 12 +- src/pug/templates/docs-help.pug | 16 +- src/py/bbctrl/v4l2.py | 14 +- 20 files changed, 950 insertions(+), 823 deletions(-) create mode 100755 scripts/new-image create mode 100755 scripts/setup.sh delete mode 100755 scripts/setup_rpi.sh create mode 100644 scripts/smb.conf create mode 100755 scripts/write-image create mode 100644 src/bbserial/yylloc.patch diff --git a/scripts/install.sh b/scripts/install.sh index 1c733dd..75dc7dd 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -5,59 +5,54 @@ UPDATE_PY=true REBOOT=false while [ $# -gt 0 ]; do - case "$1" in - --no-avr) UPDATE_AVR=false ;; - --no-py) UPDATE_PY=false ;; - esac - shift 1 + case "$1" in + --no-avr) UPDATE_AVR=false ;; + --no-py) UPDATE_PY=false ;; + esac + shift 1 done if $UPDATE_PY; then - systemctl stop bbctrl - - # Update service - mkdir -p /var/lib/bbctrl - rm -f /etc/init.d/bbctrl - install scripts/bbctrl.service /etc/systemd/system/ - systemctl daemon-reload - systemctl enable bbctrl + systemctl stop bbctrl + + # Update service + mkdir -p /var/lib/bbctrl + rm -f /etc/init.d/bbctrl + install scripts/bbctrl.service /etc/systemd/system/ + systemctl daemon-reload + systemctl enable bbctrl fi if $UPDATE_AVR; then - ./scripts/avr109-flash.py src/avr/bbctrl-avr-firmware.hex + ./scripts/avr109-flash.py src/avr/bbctrl-avr-firmware.hex fi # Update config.txt ./scripts/edit-boot-config max_usb_current=1 ./scripts/edit-boot-config config_hdmi_boost=8 -# TODO Enable GPU -#./scripts/edit-boot-config dtoverlay=vc4-kms-v3d -#./scripts/edit-boot-config gpu_mem=16 -#chmod ug+s /usr/lib/xorg/Xorg - # Fix camera grep dwc_otg.fiq_fsm_mask /boot/cmdline.txt >/dev/null if [ $? -ne 0 ]; then - mount -o remount,rw /boot && + mount -o remount,rw /boot && sed -i 's/\(.*\)/\1 dwc_otg.fiq_fsm_mask=0x3/' /boot/cmdline.txt - mount -o remount,ro /boot - REBOOT=true + mount -o remount,ro /boot + REBOOT=true fi # Enable memory cgroups grep cgroup_memory /boot/cmdline.txt >/dev/null if [ $? -ne 0 ]; then - mount -o remount,rw /boot && + mount -o remount,rw /boot && sed -i 's/\(.*\)/\1 cgroup_memory=1/' /boot/cmdline.txt - mount -o remount,ro /boot - REBOOT=true + mount -o remount,ro /boot + REBOOT=true fi # Remove Hawkeye if [ -e /etc/init.d/hawkeye ]; then - apt-get remove --purge -y hawkeye + apt-get remove --purge -y hawkeye fi # Decrease boot delay @@ -81,8 +76,8 @@ fi # Increase swap grep 'CONF_SWAPSIZE=1000' /etc/dphys-swapfile >/dev/null if [ $? -ne 0 ]; then - sed -i 's/^CONF_SWAPSIZE=.*$/CONF_SWAPSIZE=1000/' /etc/dphys-swapfile - REBOOT=true + sed -i 's/^CONF_SWAPSIZE=.*$/CONF_SWAPSIZE=1000/' /etc/dphys-swapfile + REBOOT=true fi # Install xinitrc @@ -96,13 +91,14 @@ MODSRC=src/bbserial/bbserial.ko MODDST=/lib/modules/$(uname -r)/kernel/drivers/tty/serial/bbserial.ko diff -q $MODSRC $MODDST 2>/dev/null >/dev/null if [ $? -ne 0 ]; then - install $MODSRC $MODDST - depmod - REBOOT=true + install $MODSRC $MODDST + depmod + REBOOT=true fi # Install splash -install -D src/splash/* /usr/share/plymouth/themes/buildbotics/ +install -D src/splash/* -t /usr/share/plymouth/themes/buildbotics/ +plymouth-set-default-theme -R buildbotics # Install rc.local install scripts/rc.local /etc/ @@ -120,16 +116,16 @@ rm -rf /home/pi/.config/chromium/Default/Extensions/pflmllfnnabikmfkkaddkoolinlf # Install bbctrl if $UPDATE_PY; then - rm -rf /usr/local/lib/python*/dist-packages/bbctrl-* - ./setup.py install --force - service bbctrl restart + rm -rf /usr/local/lib/python*/dist-packages/bbctrl-* + ./setup.py install --force + service bbctrl restart fi sync if $REBOOT; then - echo "Rebooting" - reboot + echo "Rebooting" + reboot fi echo "Install complete" diff --git a/scripts/new-image b/scripts/new-image new file mode 100755 index 0000000..b5c83da --- /dev/null +++ b/scripts/new-image @@ -0,0 +1,38 @@ +#!/bin/bash -e + +IMG="$1" +NEW="$2" +SIZE=$(( 26 * 1024 * 1024 * 1024 / 10 )) +VERSION=$(jq .version < package.json | tr -d \") +PKG=dist/bbctrl-$VERSION.tar.bz2 +LOOP=/dev/loop5 + +if [ ! -e "$IMG" -o "$NEW" == "" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Copy base image +cp "$IMG" "$NEW" + +# Increase disk size +dd if=/dev/null of="$NEW" bs=1 count=1 seek=$SIZE + +# Grow partition +growpart "$NEW" 2 + +# Resize filesystem +sudo losetup $LOOP "$NEW" +sudo partprobe $LOOP +sudo e2fsck -f ${LOOP}p2 +sudo resize2fs ${LOOP}p2 +sudo losetup -d $LOOP + +# Remove old bbctrl packages +rm -f rpi-share/bbctrl-*.tar.bz2 + +# Copy files +cp $PKG scripts/setup.sh rpi-share + +# Run setup script +sudo ./scripts/rpi-chroot.sh "$NEW" /mnt/host/setup.sh diff --git a/scripts/rc.local b/scripts/rc.local index 43e549a..ba7b524 100755 --- a/scripts/rc.local +++ b/scripts/rc.local @@ -9,22 +9,26 @@ modprobe -r bbserial modprobe bbserial # Set SPI GPIO mode -gpio mode 27 alt3 +gpio -g mode 16 alt3 # Does not work on Pi4 but it's set in /boot/config.txt # Create browser memory limited cgroup if [ -d sys/fs/cgroup/memory ]; then - CGROUP=/sys/fs/cgroup/memory/chrome - mkdir $CGROUP - chown -R pi:pi $CGROUP - echo 650000000 > $CGROUP/memory.soft_limit_in_bytes - echo 750000000 > $CGROUP/memory.limit_in_bytes + TOTALMEM=$(grep MemTotal /proc/meminfo | sed 's/[^0-9]*\([0-9]*\).*/\1/') + SOFTLIMIT=$(($TOTALMEM * 1024 * 2/3)) + HARDLIMIT=$(($TOTALMEM * 1024 * 3/4)) + + CGROUP=/sys/fs/cgroup/memory/chrome + mkdir $CGROUP + chown -R pi:pi $CGROUP + echo $SOFTLIMIT > $CGROUP/memory.soft_limit_in_bytes + echo $HARDLIMIT > $CGROUP/memory.limit_in_bytes fi # Reload udev /etc/init.d/udev restart -# Stop boot splash so it doesn't interfere with X if GPU enabled and to save CPU -plymouth quit +# Stop boot splash so it doesn't interfere with X if GPU enabled +plymouth quit --retain-splash # Start X in /home/pi cd /home/pi diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000..1df92c9 --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,125 @@ +#!/bin/bash -ex + +export LC_ALL=C +export DEBIAN_FRONTEND=noninteractive +cd /mnt/host + +# Update the system +apt-get update +apt-get dist-upgrade -y + +# Install packages +echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections +echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections +apt-get install -yq avahi-daemon avrdude minicom python3-pip python3-smbus \ + i2c-tools python3-rpi.gpio libjpeg8 wiringpi dnsmasq hostapd \ + iptables-persistent chromium-browser xorg rpd-plym-splash samba \ + samba-common-bin smbclient cifs-utils ratpoison libpython3.5 +pip3 install --upgrade tornado sockjs-tornado pyserial + +# Clean up +apt-get autoremove -y +apt-get autoclean -y +apt-get clean + +# Enable avahi +update-rc.d avahi-daemon defaults + +# Change hostname +sed -i "s/raspberrypi/bbctrl/" /etc/hosts /etc/hostname + +# Create bbmc user +if ! getent passwd bbmc >/dev/null; then + useradd -m -p $(openssl passwd -1 buildbotics) -s /bin/bash bbmc +fi +adduser bbmc pi +adduser bbmc sudo +passwd -l pi + +# Boot command line +cat < /boot/cmdline.txt +root=/dev/mmcblk0p2 rootfstype=ext4 rootwait elevator=deadline fsck.repair=yes \ +quiet splash logo.nologo plymouth.ignore-serial-consoles cgroup_memory=1 \ +cgroup_enable=memory dwc_otg.fiq_fsm_mask=0x3 \ +init=/usr/lib/raspi-config/init_resize.sh +EOF + +# Boot config +cat < /boot/config.txt +disable_overscan=1 +dtparam=audio=on +disable_splash=1 +initial_turbo=30 +force_eeprom_read=0 +dtparam=i2c_arm=on + +[pi4] +dtoverlay=vc4-fkms-v3d +max_framebuffers=2 + +[all] +dtoverlay=pi3-disable-bt +nohz=on +max_usb_current=1 +config_hdmi_boost=8 +gpio=16=a3 +EOF + +# Enable I2C +cat < /etc/modules-load.d/bbctrl.conf +i2c-bcm2708 +i2c-dev +EOF + +# Disable Pi 3 USART BlueTooth swap +rm -f /etc/systemd/system/multi-user.target.wants/hciuart.service + +# Enable ssh +touch /boot/ssh + +# Fix boot +sed -i 's/^PARTUUID=.*\/boot/\/dev\/mmcblk0p1 \/boot/' /etc/fstab +sed -i 's/^PARTUUID=.*\//\/dev\/mmcblk0p2 \//' /etc/fstab + +# Enable browser in xorg +sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config +( + echo 'Section "ServerFlags"' + echo ' Option "DontVTSwitch" "on"' + echo 'EndSection' +) > /etc/X11/xorg.conf + +# Samba +echo -e "buildbotics\nbuildbotics" | smbpasswd -a bbmc +cat < /etc/samba/smb.conf +[global] +netbios name = Buildbotics +server string = Buildbotics CNC Controller +wins support = yes +workgroup = WORKGROUP + +[buildbotics] +path = /var/lib/bbctrl/upload +browseable = yes +read only = no +writeable = yes +create mask = 0777 +directory mask = 0777 +public = no +EOF + +# Allow any user to shutdown +chmod +s /sbin/{halt,reboot,shutdown,poweroff} + +# Install bbctrl +PKG=$(ls /mnt/host/bbctrl-*.tar.bz2 | head -1) +if [ -e "$PKG" ]; then + PKGDIR=$(basename $PKG .tar.bz2) + tar xf $PKG + cd $PKGDIR + ./scripts/install.sh --no-avr + cd .. + rm -rf $PKGDIR +fi + +echo Setup complete diff --git a/scripts/setup_rpi.sh b/scripts/setup_rpi.sh deleted file mode 100755 index 8da1b88..0000000 --- a/scripts/setup_rpi.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -e - -export LC_ALL=C -cd /mnt/host - -# Update the system -apt-get update -apt-get dist-upgrade -y - -# Install packages -apt-get install -y avahi-daemon avrdude minicom python3-pip python3-smbus \ - i2c-tools python3-rpi.gpio libjpeg8 wiringpi dnsmasq hostapd \ - iptables-persistent chromium-browser xorg rpd-plym-splash samba \ - samba-common-bin smbclient cifs-utils ratpoison libpython3.5 -pip3 install --upgrade tornado sockjs-tornado pyserial - -# Clean -apt-get autoclean - -# Enable avahi -update-rc.d avahi-daemon defaults - -# Change hostname -sed -i "s/raspberrypi/bbctrl/" /etc/hosts /etc/hostname - -# Create bbmc user -useradd -m -p $(openssl passwd -1 buildbotics) -s /bin/bash bbmc -sed -i 's/pi$/pi,bbmc/g' /etc/group -passwd -l pi - -# Disable console on serial port -sed -i 's/console=[a-zA-Z0-9]*,115200 \?//' /boot/cmdline.txt - -# Disable i2c HAT ID probe -echo -n " bcm2708.vc_i2c_override=1" >> /boot/cmdline.txt - -# Enable I2C -sed -i 's/#dtparam=i2c/dtparam=i2c/' /boot/config.txt -#echo 'dtparam=i2c_vc=on' >> /boot/config.txt -echo i2c-bcm2708 >> /etc/modules -echo i2c-dev >> /etc/modules - -# Disable Pi 3 USART BlueTooth swap -echo -e "\ndtoverlay=pi3-disable-bt" >> /boot/config.txt -rm -f /etc/systemd/system/multi-user.target.wants/hciuart.service - -# Disable HDMI to save power and remount /boot read-only -sed -i 's/^exit 0$//' /etc/rc.local -echo "mount -o remount,ro /boot" >> /etc/rc.local -echo "gpio mode 27 alt3" >> /etc/rc.local # Enable serial CTS on pin 27 - -# Dynamic clock to save power -echo -e "\n# Dynamic clock\nnohz=on" >> /boot/config.txt - -# Shave 2 sec off of boot time -echo -e "\n# Faster boot\ndtparam=sd_overclock=100" >> /boot/config.txt - -# Enable ssh -touch /boot/ssh - -# Fix boot -sed -i 's/ root=[^ ]* / root=\/dev\/mmcblk0p2/' /boot/cmdline.txt -sed -i 's/^PARTUUID=.*\/boot/\/dev\/mmcblk0p1 \/boot/' /etc/fstab -sed -i 's/^PARTUUID=.*\//\/dev\/mmcblk0p2 \//' /etc/fstab - -# Enable browser in xorg -sed -i 's/allowed_users=console/allowed_users=anybody/' /etc/X11/Xwrapper.config -echo "sudo -u pi startx" >> /etc/rc.local -cp /mnt/host/xinitrc /home/pi/.xinitrc -cp /mnt/host/ratpoisonrc /home/pi/.ratpoisonrc -cp /mnt/host/xorg.conf /etc/X11/ - -# Set screen resolution -sed -i 's/^#disable_overscan/disable_overscan/' /boot/config.txt -sed -i 's/^#framebuffer_/framebuffer_/' /boot/config.txt - -# Boot splash -mkdir -p /usr/share/plymouth/themes/buildbotics/ -cp -av /mnt/host/splash/* /usr/share/plymouth/themes/buildbotics/ -echo -n " quiet splash logo.nologo plymouth.ignore-serial-consoles" >> /boot/cmdline.txt -plymouth-set-default-theme -R buildbotics - -# Samba -# TODO install custom smb.conf -smbpasswd -a bbmc - -# Install bbctrl -tar xf /mnt/host/bbctrl-*.tar.bz2 -cd $(basename bbctrl-*.tar.bz2 .tar.bz2) -./scripts/install.sh -cd .. -rm -rf $(basename bbctrl-*.tar.bz2 .tar.bz2) - - -# Allow any user to shutdown -chmod +s /sbin/{halt,reboot,shutdown,poweroff} - -# Clean up -apt-get autoremove -y -apt-get autoclean -y -apt-get clean diff --git a/scripts/smb.conf b/scripts/smb.conf new file mode 100644 index 0000000..d2086ec --- /dev/null +++ b/scripts/smb.conf @@ -0,0 +1,30 @@ +[global] +workgroup = WORKGROUP +wins support = yes +dns proxy = no + +log file = /var/log/samba/log.%m +max log size = 1000 +syslog = 0 +panic action = /usr/share/samba/panic-action %d + +server role = standalone server +passdb backend = tdbsam +obey pam restrictions = yes +unix password sync = yes + +passwd program = /usr/bin/passwd %u +passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . +pam password change = yes + +map to guest = bad user +usershare allow guests = yes + +[upload] +path=/var/lib/bbctrl/upload +browseable=Yes +writeable=Yes +only guest=no +create mask=0666 +directory mask=0777 +public=no diff --git a/scripts/write-image b/scripts/write-image new file mode 100755 index 0000000..d5fb1a7 --- /dev/null +++ b/scripts/write-image @@ -0,0 +1,14 @@ +#!/bin/bash -e + +IMG="$1" +DEV="$2" + +if [ ! -e "$IMG" -o ! -e "$DEV" ]; then + echo "Usage: $0 " + exit 1 +fi + +SIZE=$(du -h "$IMG" | cut -f1) +echo "Writing ${SIZE}iB to $DEV" + +sudo dd if="$IMG" bs=10M of="$DEV" status=progress oflag=direct conv=fdatasync diff --git a/scripts/xinitrc b/scripts/xinitrc index 4ae3cc6..b141675 100755 --- a/scripts/xinitrc +++ b/scripts/xinitrc @@ -5,6 +5,14 @@ xset -dpms xset s off xset s noblank +OPTS=--no-first-run --disable-infobars --noerrdialogs + +# No GPU on Pi 3 +cat /proc/cpuinfo | grep "Pi 3 Model" >/dev/null +if [ $? -eq 0 ]; then + OPTS=$OPTS --disable-3d-apis +fi + while true; do tvservice -s 2>&1 | grep "state 0x40001" >/dev/null if [ $? -ne 0 ]; then @@ -14,8 +22,7 @@ while true; do sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' $PREFS # Start browser - /usr/local/bin/browser --no-first-run --disable-infobars \ - --noerrdialogs --disable-3d-apis http://localhost/ + /usr/local/bin/browser $OPTS http://localhost/ fi sleep 1 diff --git a/src/avr/src/usart.c b/src/avr/src/usart.c index 4198bc1..d5345af 100644 --- a/src/avr/src/usart.c +++ b/src/avr/src/usart.c @@ -109,7 +109,6 @@ static void _set_baud(USART_t *port, uint16_t bsel, uint8_t bscale) { void usart_set_baud(USART_t *port, baud_t baud) { // The BSEL / BSCALE values provided below assume a 32 Mhz clock // With CTRLB CLK2X is set - // See http://www.avrcalc.elektronik-projekt.de/xmega/baud_rate_calculator switch (baud) { case USART_BAUD_9600: _set_baud(port, 3325, 0b1101); break; diff --git a/src/bbserial/.gitignore b/src/bbserial/.gitignore index a90b6ca..4d71810 100644 --- a/src/bbserial/.gitignore +++ b/src/bbserial/.gitignore @@ -6,3 +6,5 @@ /*.o /kernel /modules.order +/*.gz +/linux-* diff --git a/src/bbserial/Makefile b/src/bbserial/Makefile index 0b7bbc6..6c4cc8a 100644 --- a/src/bbserial/Makefile +++ b/src/bbserial/Makefile @@ -3,9 +3,10 @@ DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) obj-m:=bbserial.o ccflags-y:=-std=gnu99 -Wno-declaration-after-statement -KPKG=raspberrypi-kernel_1.20171029-1.tar.gz -KURL=https://github.com/dbrgn/linux-rpi/archive/$(KPKG) -KDIR=linux-rpi-raspberrypi-kernel_1.20171029-1 +KVER=1.20171029-1 +KPKG=raspberrypi-kernel_$(KVER).tar.gz +KURL=https://github.com/raspberrypi/linux/archive/$(KPKG) +KDIR=linux-raspberrypi-kernel_$(KVER) export KERNEL=kernel7 KOPTS=ARCH=arm CROSS_COMPILE=$(CROSS) -C $(KDIR) @@ -15,6 +16,7 @@ all: $(KDIR) $(KDIR): $(KPKG) tar xf $(KPKG) + patch -p1 < yylloc.patch $(MAKE) $(KOPTS) bcm2709_defconfig $(MAKE) $(KOPTS) modules_prepare diff --git a/src/bbserial/bbserial.c b/src/bbserial/bbserial.c index 1c5a536..08cb5cb 100644 --- a/src/bbserial/bbserial.c +++ b/src/bbserial/bbserial.c @@ -459,7 +459,7 @@ static long _dev_ioctl(struct file *file, unsigned cmd, unsigned long arg) { switch (cmd) { case TCGETS: { // Get serial port settings struct ktermios *term = _get_term(); - if (copy_to_user((void __user *)arg, &term, sizeof(struct termios))) + if (copy_to_user((void __user *)arg, term, sizeof(struct termios))) return -EFAULT; return 0; } diff --git a/src/bbserial/yylloc.patch b/src/bbserial/yylloc.patch new file mode 100644 index 0000000..3203a9e --- /dev/null +++ b/src/bbserial/yylloc.patch @@ -0,0 +1,12 @@ +diff -Naru a/linux-raspberrypi-kernel_1.20171029-1/scripts/dtc/dtc-lexer.lex.c_shipped b/linux-raspberrypi-kernel_1.20171029-1/scripts/dtc/dtc-lexer.lex.c_shipped +--- a/linux-raspberrypi-kernel_1.20171029-1/scripts/dtc/dtc-lexer.lex.c_shipped 2017-10-29 02:58:27.000000000 -0700 ++++ b/linux-raspberrypi-kernel_1.20171029-1/scripts/dtc/dtc-lexer.lex.c_shipped 2021-05-01 21:03:23.119940735 -0700 +@@ -639,7 +639,7 @@ + #include "srcpos.h" + #include "dtc-parser.tab.h" + +-YYLTYPE yylloc; ++extern YYLTYPE yylloc; + extern bool treesource_error; + + /* CAUTION: this will stop working if we ever use yyless() or yyunput() */ diff --git a/src/boot/src/sp_driver.S b/src/boot/src/sp_driver.S index bbb1ee7..6e3d6f4 100644 --- a/src/boot/src/sp_driver.S +++ b/src/boot/src/sp_driver.S @@ -62,7 +62,7 @@ ;* For comprehensive code documentation, supported compilers, compiler ;* settings and supported devices see readme.html ;* -;* Atmel Corporation: http:;www.atmel.com \n +;* Atmel Corporation: https://www.atmel.com ;* Support email: avr@atmel.com #include diff --git a/src/boot/src/sp_driver.h b/src/boot/src/sp_driver.h index 080bffa..a06c703 100644 --- a/src/boot/src/sp_driver.h +++ b/src/boot/src/sp_driver.h @@ -83,7 +83,7 @@ * settings and supported devices see readme.html * * \author - * Atmel Corporation: http://www.atmel.com + * Atmel Corporation: https://www.atmel.com * Support email: avr@atmel.com ******************************************************************************/ diff --git a/src/jig/src/usart.c b/src/jig/src/usart.c index 1cf2b07..c195976 100644 --- a/src/jig/src/usart.c +++ b/src/jig/src/usart.c @@ -137,7 +137,6 @@ static void _set_baud(uint16_t bsel, uint8_t bscale) { void usart_set_baud(int baud) { // The BSEL / BSCALE values provided below assume a 32 Mhz clock // Assumes CTRLB CLK2X bit (0x04) is set - // See http://www.avrcalc.elektronik-projekt.de/xmega/baud_rate_calculator switch (baud) { case USART_BAUD_9600: _set_baud(3325, 0b1101); break; diff --git a/src/js/orbit.js b/src/js/orbit.js index 3ad5e34..0c9742b 100644 --- a/src/js/orbit.js +++ b/src/js/orbit.js @@ -26,12 +26,12 @@ \******************************************************************************/ /** - * @author qiao / https://github.com/qiao - * @author mrdoob / http://mrdoob.com - * @author alteredq / http://alteredqualia.com/ - * @author WestLangley / http://github.com/WestLangley - * @author erich666 / http://erichaines.com - * @author ScieCode / http://github.com/sciecode + * @author qiao / https://github.com/qiao + * @author mrdoob / https://mrdoob.com + * @author alteredq / https://alteredqualia.com/ + * @author WestLangley / https://github.com/WestLangley + * @author erich666 / https://erichaines.com + * @author ScieCode / https://github.com/sciecode */ // This set of controls performs orbiting, dollying (zooming), and panning. @@ -43,1139 +43,1139 @@ THREE.OrbitControls = function ( object, domElement ) { - if ( domElement === undefined ) console.warn( 'THREE.OrbitControls: The second parameter "domElement" is now mandatory.' ); - if ( domElement === document ) console.error( 'THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.' ); + if ( domElement === undefined ) console.warn( 'THREE.OrbitControls: The second parameter "domElement" is now mandatory.' ); + if ( domElement === document ) console.error( 'THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.' ); - this.object = object; - this.domElement = domElement; + this.object = object; + this.domElement = domElement; - // Set to false to disable this control - this.enabled = true; + // Set to false to disable this control + this.enabled = true; - // "target" sets the location of focus, where the object orbits around - this.target = new THREE.Vector3(); + // "target" sets the location of focus, where the object orbits around + this.target = new THREE.Vector3(); - // How far you can dolly in and out ( PerspectiveCamera only ) - this.minDistance = 0; - this.maxDistance = Infinity; + // How far you can dolly in and out ( PerspectiveCamera only ) + this.minDistance = 0; + this.maxDistance = Infinity; - // How far you can zoom in and out ( OrthographicCamera only ) - this.minZoom = 0; - this.maxZoom = Infinity; + // How far you can zoom in and out ( OrthographicCamera only ) + this.minZoom = 0; + this.maxZoom = Infinity; - // How far you can orbit vertically, upper and lower limits. - // Range is 0 to Math.PI radians. - this.minPolarAngle = 0; // radians - this.maxPolarAngle = Math.PI; // radians + // How far you can orbit vertically, upper and lower limits. + // Range is 0 to Math.PI radians. + this.minPolarAngle = 0; // radians + this.maxPolarAngle = Math.PI; // radians - // How far you can orbit horizontally, upper and lower limits. - // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ]. - this.minAzimuthAngle = - Infinity; // radians - this.maxAzimuthAngle = Infinity; // radians + // How far you can orbit horizontally, upper and lower limits. + // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ]. + this.minAzimuthAngle = - Infinity; // radians + this.maxAzimuthAngle = Infinity; // radians - // Set to true to enable damping (inertia) - // If damping is enabled, you must call controls.update() in your animation loop - this.enableDamping = false; - this.dampingFactor = 0.05; + // Set to true to enable damping (inertia) + // If damping is enabled, you must call controls.update() in your animation loop + this.enableDamping = false; + this.dampingFactor = 0.05; - // This option actually enables dollying in and out; left as "zoom" for backwards compatibility. - // Set to false to disable zooming - this.enableZoom = true; - this.zoomSpeed = 1.0; + // This option actually enables dollying in and out; left as "zoom" for backwards compatibility. + // Set to false to disable zooming + this.enableZoom = true; + this.zoomSpeed = 1.0; - // Set to false to disable rotating - this.enableRotate = true; - this.rotateSpeed = 1.0; + // Set to false to disable rotating + this.enableRotate = true; + this.rotateSpeed = 1.0; - // Set to false to disable panning - this.enablePan = true; - this.panSpeed = 1.0; - this.screenSpacePanning = false; // if true, pan in screen-space - this.keyPanSpeed = 7.0; // pixels moved per arrow key push + // Set to false to disable panning + this.enablePan = true; + this.panSpeed = 1.0; + this.screenSpacePanning = false; // if true, pan in screen-space + this.keyPanSpeed = 7.0; // pixels moved per arrow key push - // Set to true to automatically rotate around the target - // If auto-rotate is enabled, you must call controls.update() in your animation loop - this.autoRotate = false; - this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60 + // Set to true to automatically rotate around the target + // If auto-rotate is enabled, you must call controls.update() in your animation loop + this.autoRotate = false; + this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60 - // Set to false to disable use of the keys - this.enableKeys = true; + // Set to false to disable use of the keys + this.enableKeys = true; - // The four arrow keys - this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 }; + // The four arrow keys + this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 }; - // Mouse buttons - this.mouseButtons = { LEFT: THREE.MOUSE.ROTATE, MIDDLE: THREE.MOUSE.DOLLY, RIGHT: THREE.MOUSE.PAN }; + // Mouse buttons + this.mouseButtons = { LEFT: THREE.MOUSE.ROTATE, MIDDLE: THREE.MOUSE.DOLLY, RIGHT: THREE.MOUSE.PAN }; - // Touch fingers - this.touches = { ONE: THREE.TOUCH.ROTATE, TWO: THREE.TOUCH.DOLLY_PAN }; + // Touch fingers + this.touches = { ONE: THREE.TOUCH.ROTATE, TWO: THREE.TOUCH.DOLLY_PAN }; - // for reset - this.target0 = this.target.clone(); - this.position0 = this.object.position.clone(); - this.zoom0 = this.object.zoom; + // for reset + this.target0 = this.target.clone(); + this.position0 = this.object.position.clone(); + this.zoom0 = this.object.zoom; - // - // public methods - // + // + // public methods + // - this.getPolarAngle = function () { + this.getPolarAngle = function () { - return spherical.phi; + return spherical.phi; - }; + }; - this.getAzimuthalAngle = function () { + this.getAzimuthalAngle = function () { - return spherical.theta; + return spherical.theta; - }; + }; - this.saveState = function () { + this.saveState = function () { - scope.target0.copy( scope.target ); - scope.position0.copy( scope.object.position ); - scope.zoom0 = scope.object.zoom; + scope.target0.copy( scope.target ); + scope.position0.copy( scope.object.position ); + scope.zoom0 = scope.object.zoom; - }; + }; - this.reset = function () { + this.reset = function () { - scope.target.copy( scope.target0 ); - scope.object.position.copy( scope.position0 ); - scope.object.zoom = scope.zoom0; + scope.target.copy( scope.target0 ); + scope.object.position.copy( scope.position0 ); + scope.object.zoom = scope.zoom0; - scope.object.updateProjectionMatrix(); - scope.dispatchEvent( changeEvent ); + scope.object.updateProjectionMatrix(); + scope.dispatchEvent( changeEvent ); - scope.update(); + scope.update(); - state = STATE.NONE; + state = STATE.NONE; - }; + }; - // this method is exposed, but perhaps it would be better if we can make it private... - this.update = function () { + // this method is exposed, but perhaps it would be better if we can make it private... + this.update = function () { - var offset = new THREE.Vector3(); + var offset = new THREE.Vector3(); - // so camera.up is the orbit axis - var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) ); - var quatInverse = quat.clone().inverse(); + // so camera.up is the orbit axis + var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) ); + var quatInverse = quat.clone().inverse(); - var lastPosition = new THREE.Vector3(); - var lastQuaternion = new THREE.Quaternion(); + var lastPosition = new THREE.Vector3(); + var lastQuaternion = new THREE.Quaternion(); - return function update() { + return function update() { - var position = scope.object.position; + var position = scope.object.position; - offset.copy( position ).sub( scope.target ); + offset.copy( position ).sub( scope.target ); - // rotate offset to "y-axis-is-up" space - offset.applyQuaternion( quat ); + // rotate offset to "y-axis-is-up" space + offset.applyQuaternion( quat ); - // angle from z-axis around y-axis - spherical.setFromVector3( offset ); + // angle from z-axis around y-axis + spherical.setFromVector3( offset ); - if ( scope.autoRotate && state === STATE.NONE ) { + if ( scope.autoRotate && state === STATE.NONE ) { - rotateLeft( getAutoRotationAngle() ); + rotateLeft( getAutoRotationAngle() ); - } + } - if ( scope.enableDamping ) { + if ( scope.enableDamping ) { - spherical.theta += sphericalDelta.theta * scope.dampingFactor; - spherical.phi += sphericalDelta.phi * scope.dampingFactor; + spherical.theta += sphericalDelta.theta * scope.dampingFactor; + spherical.phi += sphericalDelta.phi * scope.dampingFactor; - } else { + } else { - spherical.theta += sphericalDelta.theta; - spherical.phi += sphericalDelta.phi; + spherical.theta += sphericalDelta.theta; + spherical.phi += sphericalDelta.phi; - } + } - // restrict theta to be between desired limits - spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) ); + // restrict theta to be between desired limits + spherical.theta = Math.max( scope.minAzimuthAngle, Math.min( scope.maxAzimuthAngle, spherical.theta ) ); - // restrict phi to be between desired limits - spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) ); + // restrict phi to be between desired limits + spherical.phi = Math.max( scope.minPolarAngle, Math.min( scope.maxPolarAngle, spherical.phi ) ); - spherical.makeSafe(); + spherical.makeSafe(); - spherical.radius *= scale; + spherical.radius *= scale; - // restrict radius to be between desired limits - spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) ); + // restrict radius to be between desired limits + spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) ); - // move target to panned location + // move target to panned location - if ( scope.enableDamping === true ) { + if ( scope.enableDamping === true ) { - scope.target.addScaledVector( panOffset, scope.dampingFactor ); + scope.target.addScaledVector( panOffset, scope.dampingFactor ); - } else { + } else { - scope.target.add( panOffset ); + scope.target.add( panOffset ); - } + } - offset.setFromSpherical( spherical ); + offset.setFromSpherical( spherical ); - // rotate offset back to "camera-up-vector-is-up" space - offset.applyQuaternion( quatInverse ); + // rotate offset back to "camera-up-vector-is-up" space + offset.applyQuaternion( quatInverse ); - position.copy( scope.target ).add( offset ); + position.copy( scope.target ).add( offset ); - scope.object.lookAt( scope.target ); + scope.object.lookAt( scope.target ); - if ( scope.enableDamping === true ) { + if ( scope.enableDamping === true ) { - sphericalDelta.theta *= ( 1 - scope.dampingFactor ); - sphericalDelta.phi *= ( 1 - scope.dampingFactor ); + sphericalDelta.theta *= ( 1 - scope.dampingFactor ); + sphericalDelta.phi *= ( 1 - scope.dampingFactor ); - panOffset.multiplyScalar( 1 - scope.dampingFactor ); + panOffset.multiplyScalar( 1 - scope.dampingFactor ); - } else { + } else { - sphericalDelta.set( 0, 0, 0 ); + sphericalDelta.set( 0, 0, 0 ); - panOffset.set( 0, 0, 0 ); + panOffset.set( 0, 0, 0 ); - } + } - scale = 1; + scale = 1; - // update condition is: - // min(camera displacement, camera rotation in radians)^2 > EPS - // using small-angle approximation cos(x/2) = 1 - x^2 / 8 + // update condition is: + // min(camera displacement, camera rotation in radians)^2 > EPS + // using small-angle approximation cos(x/2) = 1 - x^2 / 8 - if ( zoomChanged || - lastPosition.distanceToSquared( scope.object.position ) > EPS || - 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) { + if ( zoomChanged || + lastPosition.distanceToSquared( scope.object.position ) > EPS || + 8 * ( 1 - lastQuaternion.dot( scope.object.quaternion ) ) > EPS ) { - scope.dispatchEvent( changeEvent ); + scope.dispatchEvent( changeEvent ); - lastPosition.copy( scope.object.position ); - lastQuaternion.copy( scope.object.quaternion ); - zoomChanged = false; + lastPosition.copy( scope.object.position ); + lastQuaternion.copy( scope.object.quaternion ); + zoomChanged = false; - return true; + return true; - } + } - return false; + return false; - }; + }; - }(); + }(); - this.dispose = function () { + this.dispose = function () { - scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false ); - scope.domElement.removeEventListener( 'mousedown', onMouseDown, false ); - scope.domElement.removeEventListener( 'wheel', onMouseWheel, false ); + scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false ); + scope.domElement.removeEventListener( 'mousedown', onMouseDown, false ); + scope.domElement.removeEventListener( 'wheel', onMouseWheel, false ); - scope.domElement.removeEventListener( 'touchstart', onTouchStart, false ); - scope.domElement.removeEventListener( 'touchend', onTouchEnd, false ); - scope.domElement.removeEventListener( 'touchmove', onTouchMove, false ); + scope.domElement.removeEventListener( 'touchstart', onTouchStart, false ); + scope.domElement.removeEventListener( 'touchend', onTouchEnd, false ); + scope.domElement.removeEventListener( 'touchmove', onTouchMove, false ); - document.removeEventListener( 'mousemove', onMouseMove, false ); - document.removeEventListener( 'mouseup', onMouseUp, false ); + document.removeEventListener( 'mousemove', onMouseMove, false ); + document.removeEventListener( 'mouseup', onMouseUp, false ); - scope.domElement.removeEventListener( 'keydown', onKeyDown, false ); + scope.domElement.removeEventListener( 'keydown', onKeyDown, false ); - //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here? + //scope.dispatchEvent( { type: 'dispose' } ); // should this be added here? - }; + }; - // - // internals - // + // + // internals + // - var scope = this; + var scope = this; - var changeEvent = { type: 'change' }; - var startEvent = { type: 'start' }; - var endEvent = { type: 'end' }; + var changeEvent = { type: 'change' }; + var startEvent = { type: 'start' }; + var endEvent = { type: 'end' }; - var STATE = { - NONE: - 1, - ROTATE: 0, - DOLLY: 1, - PAN: 2, - TOUCH_ROTATE: 3, - TOUCH_PAN: 4, - TOUCH_DOLLY_PAN: 5, - TOUCH_DOLLY_ROTATE: 6 - }; + var STATE = { + NONE: - 1, + ROTATE: 0, + DOLLY: 1, + PAN: 2, + TOUCH_ROTATE: 3, + TOUCH_PAN: 4, + TOUCH_DOLLY_PAN: 5, + TOUCH_DOLLY_ROTATE: 6 + }; - var state = STATE.NONE; + var state = STATE.NONE; - var EPS = 0.000001; + var EPS = 0.000001; - // current position in spherical coordinates - var spherical = new THREE.Spherical(); - var sphericalDelta = new THREE.Spherical(); + // current position in spherical coordinates + var spherical = new THREE.Spherical(); + var sphericalDelta = new THREE.Spherical(); - var scale = 1; - var panOffset = new THREE.Vector3(); - var zoomChanged = false; + var scale = 1; + var panOffset = new THREE.Vector3(); + var zoomChanged = false; - var rotateStart = new THREE.Vector2(); - var rotateEnd = new THREE.Vector2(); - var rotateDelta = new THREE.Vector2(); + var rotateStart = new THREE.Vector2(); + var rotateEnd = new THREE.Vector2(); + var rotateDelta = new THREE.Vector2(); - var panStart = new THREE.Vector2(); - var panEnd = new THREE.Vector2(); - var panDelta = new THREE.Vector2(); + var panStart = new THREE.Vector2(); + var panEnd = new THREE.Vector2(); + var panDelta = new THREE.Vector2(); - var dollyStart = new THREE.Vector2(); - var dollyEnd = new THREE.Vector2(); - var dollyDelta = new THREE.Vector2(); + var dollyStart = new THREE.Vector2(); + var dollyEnd = new THREE.Vector2(); + var dollyDelta = new THREE.Vector2(); - function getAutoRotationAngle() { + function getAutoRotationAngle() { - return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed; + return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed; - } + } - function getZoomScale() { + function getZoomScale() { - return Math.pow( 0.95, scope.zoomSpeed ); + return Math.pow( 0.95, scope.zoomSpeed ); - } + } - function rotateLeft( angle ) { + function rotateLeft( angle ) { - sphericalDelta.theta -= angle; + sphericalDelta.theta -= angle; - } + } - function rotateUp( angle ) { + function rotateUp( angle ) { - sphericalDelta.phi -= angle; + sphericalDelta.phi -= angle; - } + } - var panLeft = function () { + var panLeft = function () { - var v = new THREE.Vector3(); + var v = new THREE.Vector3(); - return function panLeft( distance, objectMatrix ) { + return function panLeft( distance, objectMatrix ) { - v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix - v.multiplyScalar( - distance ); + v.setFromMatrixColumn( objectMatrix, 0 ); // get X column of objectMatrix + v.multiplyScalar( - distance ); - panOffset.add( v ); + panOffset.add( v ); - }; + }; - }(); + }(); - var panUp = function () { + var panUp = function () { - var v = new THREE.Vector3(); + var v = new THREE.Vector3(); - return function panUp( distance, objectMatrix ) { + return function panUp( distance, objectMatrix ) { - if ( scope.screenSpacePanning === true ) { + if ( scope.screenSpacePanning === true ) { - v.setFromMatrixColumn( objectMatrix, 1 ); + v.setFromMatrixColumn( objectMatrix, 1 ); - } else { + } else { - v.setFromMatrixColumn( objectMatrix, 0 ); - v.crossVectors( scope.object.up, v ); + v.setFromMatrixColumn( objectMatrix, 0 ); + v.crossVectors( scope.object.up, v ); - } + } - v.multiplyScalar( distance ); + v.multiplyScalar( distance ); - panOffset.add( v ); + panOffset.add( v ); - }; + }; - }(); + }(); - // deltaX and deltaY are in pixels; right and down are positive - var pan = function () { + // deltaX and deltaY are in pixels; right and down are positive + var pan = function () { - var offset = new THREE.Vector3(); + var offset = new THREE.Vector3(); - return function pan( deltaX, deltaY ) { + return function pan( deltaX, deltaY ) { - var element = scope.domElement; + var element = scope.domElement; - if ( scope.object.isPerspectiveCamera ) { + if ( scope.object.isPerspectiveCamera ) { - // perspective - var position = scope.object.position; - offset.copy( position ).sub( scope.target ); - var targetDistance = offset.length(); + // perspective + var position = scope.object.position; + offset.copy( position ).sub( scope.target ); + var targetDistance = offset.length(); - // half of the fov is center to top of screen - targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 ); + // half of the fov is center to top of screen + targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 ); - // we use only clientHeight here so aspect ratio does not distort speed - panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix ); - panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix ); + // we use only clientHeight here so aspect ratio does not distort speed + panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix ); + panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix ); - } else if ( scope.object.isOrthographicCamera ) { + } else if ( scope.object.isOrthographicCamera ) { - // orthographic - panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix ); - panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix ); + // orthographic + panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix ); + panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix ); - } else { + } else { - // camera neither orthographic nor perspective - console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' ); - scope.enablePan = false; + // camera neither orthographic nor perspective + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' ); + scope.enablePan = false; - } + } - }; + }; - }(); + }(); - function dollyIn( dollyScale ) { + function dollyIn( dollyScale ) { - if ( scope.object.isPerspectiveCamera ) { + if ( scope.object.isPerspectiveCamera ) { - scale /= dollyScale; + scale /= dollyScale; - } else if ( scope.object.isOrthographicCamera ) { + } else if ( scope.object.isOrthographicCamera ) { - scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) ); - scope.object.updateProjectionMatrix(); - zoomChanged = true; + scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom * dollyScale ) ); + scope.object.updateProjectionMatrix(); + zoomChanged = true; - } else { + } else { - console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); - scope.enableZoom = false; + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); + scope.enableZoom = false; - } + } - } + } - function dollyOut( dollyScale ) { + function dollyOut( dollyScale ) { - if ( scope.object.isPerspectiveCamera ) { + if ( scope.object.isPerspectiveCamera ) { - scale *= dollyScale; + scale *= dollyScale; - } else if ( scope.object.isOrthographicCamera ) { + } else if ( scope.object.isOrthographicCamera ) { - scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) ); - scope.object.updateProjectionMatrix(); - zoomChanged = true; + scope.object.zoom = Math.max( scope.minZoom, Math.min( scope.maxZoom, scope.object.zoom / dollyScale ) ); + scope.object.updateProjectionMatrix(); + zoomChanged = true; - } else { + } else { - console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); - scope.enableZoom = false; + console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' ); + scope.enableZoom = false; - } + } - } + } - // - // event callbacks - update the object state - // + // + // event callbacks - update the object state + // - function handleMouseDownRotate( event ) { + function handleMouseDownRotate( event ) { - rotateStart.set( event.clientX, event.clientY ); + rotateStart.set( event.clientX, event.clientY ); - } + } - function handleMouseDownDolly( event ) { + function handleMouseDownDolly( event ) { - dollyStart.set( event.clientX, event.clientY ); + dollyStart.set( event.clientX, event.clientY ); - } + } - function handleMouseDownPan( event ) { + function handleMouseDownPan( event ) { - panStart.set( event.clientX, event.clientY ); + panStart.set( event.clientX, event.clientY ); - } + } - function handleMouseMoveRotate( event ) { + function handleMouseMoveRotate( event ) { - rotateEnd.set( event.clientX, event.clientY ); + rotateEnd.set( event.clientX, event.clientY ); - rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); + rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); - var element = scope.domElement; + var element = scope.domElement; - rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height + rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height - rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); + rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); - rotateStart.copy( rotateEnd ); + rotateStart.copy( rotateEnd ); - scope.update(); + scope.update(); - } + } - function handleMouseMoveDolly( event ) { + function handleMouseMoveDolly( event ) { - dollyEnd.set( event.clientX, event.clientY ); + dollyEnd.set( event.clientX, event.clientY ); - dollyDelta.subVectors( dollyEnd, dollyStart ); + dollyDelta.subVectors( dollyEnd, dollyStart ); - if ( dollyDelta.y > 0 ) { + if ( dollyDelta.y > 0 ) { - dollyIn( getZoomScale() ); + dollyIn( getZoomScale() ); - } else if ( dollyDelta.y < 0 ) { + } else if ( dollyDelta.y < 0 ) { - dollyOut( getZoomScale() ); + dollyOut( getZoomScale() ); - } + } - dollyStart.copy( dollyEnd ); + dollyStart.copy( dollyEnd ); - scope.update(); + scope.update(); - } + } - function handleMouseMovePan( event ) { + function handleMouseMovePan( event ) { - panEnd.set( event.clientX, event.clientY ); + panEnd.set( event.clientX, event.clientY ); - panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); + panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); - pan( panDelta.x, panDelta.y ); + pan( panDelta.x, panDelta.y ); - panStart.copy( panEnd ); + panStart.copy( panEnd ); - scope.update(); + scope.update(); - } + } - function handleMouseUp( /*event*/ ) { + function handleMouseUp( /*event*/ ) { - // no-op + // no-op - } + } - function handleMouseWheel( event ) { + function handleMouseWheel( event ) { - if ( event.deltaY < 0 ) { + if ( event.deltaY < 0 ) { - dollyOut( getZoomScale() ); + dollyOut( getZoomScale() ); - } else if ( event.deltaY > 0 ) { + } else if ( event.deltaY > 0 ) { - dollyIn( getZoomScale() ); + dollyIn( getZoomScale() ); - } + } - scope.update(); + scope.update(); - } + } - function handleKeyDown( event ) { + function handleKeyDown( event ) { - var needsUpdate = false; + var needsUpdate = false; - switch ( event.keyCode ) { + switch ( event.keyCode ) { - case scope.keys.UP: - pan( 0, scope.keyPanSpeed ); - needsUpdate = true; - break; + case scope.keys.UP: + pan( 0, scope.keyPanSpeed ); + needsUpdate = true; + break; - case scope.keys.BOTTOM: - pan( 0, - scope.keyPanSpeed ); - needsUpdate = true; - break; + case scope.keys.BOTTOM: + pan( 0, - scope.keyPanSpeed ); + needsUpdate = true; + break; - case scope.keys.LEFT: - pan( scope.keyPanSpeed, 0 ); - needsUpdate = true; - break; + case scope.keys.LEFT: + pan( scope.keyPanSpeed, 0 ); + needsUpdate = true; + break; - case scope.keys.RIGHT: - pan( - scope.keyPanSpeed, 0 ); - needsUpdate = true; - break; + case scope.keys.RIGHT: + pan( - scope.keyPanSpeed, 0 ); + needsUpdate = true; + break; - } + } - if ( needsUpdate ) { + if ( needsUpdate ) { - // prevent the browser from scrolling on cursor keys - event.preventDefault(); + // prevent the browser from scrolling on cursor keys + event.preventDefault(); - scope.update(); + scope.update(); - } + } - } + } - function handleTouchStartRotate( event ) { + function handleTouchStartRotate( event ) { - if ( event.touches.length == 1 ) { + if ( event.touches.length == 1 ) { - rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); + rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); - } else { + } else { - var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); - var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); + var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); + var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); - rotateStart.set( x, y ); + rotateStart.set( x, y ); - } + } - } + } - function handleTouchStartPan( event ) { + function handleTouchStartPan( event ) { - if ( event.touches.length == 1 ) { + if ( event.touches.length == 1 ) { - panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); + panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); - } else { + } else { - var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); - var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); + var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); + var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); - panStart.set( x, y ); + panStart.set( x, y ); - } + } - } + } - function handleTouchStartDolly( event ) { + function handleTouchStartDolly( event ) { - var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; - var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; + var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; + var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; - var distance = Math.sqrt( dx * dx + dy * dy ); + var distance = Math.sqrt( dx * dx + dy * dy ); - dollyStart.set( 0, distance ); + dollyStart.set( 0, distance ); - } + } - function handleTouchStartDollyPan( event ) { + function handleTouchStartDollyPan( event ) { - if ( scope.enableZoom ) handleTouchStartDolly( event ); + if ( scope.enableZoom ) handleTouchStartDolly( event ); - if ( scope.enablePan ) handleTouchStartPan( event ); + if ( scope.enablePan ) handleTouchStartPan( event ); - } + } - function handleTouchStartDollyRotate( event ) { + function handleTouchStartDollyRotate( event ) { - if ( scope.enableZoom ) handleTouchStartDolly( event ); + if ( scope.enableZoom ) handleTouchStartDolly( event ); - if ( scope.enableRotate ) handleTouchStartRotate( event ); + if ( scope.enableRotate ) handleTouchStartRotate( event ); - } + } - function handleTouchMoveRotate( event ) { + function handleTouchMoveRotate( event ) { - if ( event.touches.length == 1 ) { + if ( event.touches.length == 1 ) { - rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); + rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); - } else { + } else { - var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); - var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); + var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); + var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); - rotateEnd.set( x, y ); + rotateEnd.set( x, y ); - } + } - rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); + rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( scope.rotateSpeed ); - var element = scope.domElement; + var element = scope.domElement; - rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height + rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height - rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); + rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); - rotateStart.copy( rotateEnd ); + rotateStart.copy( rotateEnd ); - } + } - function handleTouchMovePan( event ) { + function handleTouchMovePan( event ) { - if ( event.touches.length == 1 ) { + if ( event.touches.length == 1 ) { - panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); + panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ); - } else { + } else { - var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); - var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); + var x = 0.5 * ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ); + var y = 0.5 * ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ); - panEnd.set( x, y ); + panEnd.set( x, y ); - } + } - panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); + panDelta.subVectors( panEnd, panStart ).multiplyScalar( scope.panSpeed ); - pan( panDelta.x, panDelta.y ); + pan( panDelta.x, panDelta.y ); - panStart.copy( panEnd ); + panStart.copy( panEnd ); - } + } - function handleTouchMoveDolly( event ) { + function handleTouchMoveDolly( event ) { - var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; - var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; + var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; + var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; - var distance = Math.sqrt( dx * dx + dy * dy ); + var distance = Math.sqrt( dx * dx + dy * dy ); - dollyEnd.set( 0, distance ); + dollyEnd.set( 0, distance ); - dollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) ); + dollyDelta.set( 0, Math.pow( dollyEnd.y / dollyStart.y, scope.zoomSpeed ) ); - dollyIn( dollyDelta.y ); + dollyIn( dollyDelta.y ); - dollyStart.copy( dollyEnd ); + dollyStart.copy( dollyEnd ); - } + } - function handleTouchMoveDollyPan( event ) { + function handleTouchMoveDollyPan( event ) { - if ( scope.enableZoom ) handleTouchMoveDolly( event ); + if ( scope.enableZoom ) handleTouchMoveDolly( event ); - if ( scope.enablePan ) handleTouchMovePan( event ); + if ( scope.enablePan ) handleTouchMovePan( event ); - } + } - function handleTouchMoveDollyRotate( event ) { + function handleTouchMoveDollyRotate( event ) { - if ( scope.enableZoom ) handleTouchMoveDolly( event ); + if ( scope.enableZoom ) handleTouchMoveDolly( event ); - if ( scope.enableRotate ) handleTouchMoveRotate( event ); + if ( scope.enableRotate ) handleTouchMoveRotate( event ); - } + } - function handleTouchEnd( /*event*/ ) { + function handleTouchEnd( /*event*/ ) { - // no-op + // no-op - } + } - // - // event handlers - FSM: listen for events and reset state - // + // + // event handlers - FSM: listen for events and reset state + // - function onMouseDown( event ) { + function onMouseDown( event ) { - if ( scope.enabled === false ) return; + if ( scope.enabled === false ) return; - // Prevent the browser from scrolling. + // Prevent the browser from scrolling. - event.preventDefault(); + event.preventDefault(); - // Manually set the focus since calling preventDefault above - // prevents the browser from setting it automatically. + // Manually set the focus since calling preventDefault above + // prevents the browser from setting it automatically. - scope.domElement.focus ? scope.domElement.focus() : window.focus(); + scope.domElement.focus ? scope.domElement.focus() : window.focus(); - switch ( event.button ) { + switch ( event.button ) { - case 0: + case 0: - switch ( scope.mouseButtons.LEFT ) { + switch ( scope.mouseButtons.LEFT ) { - case THREE.MOUSE.ROTATE: + case THREE.MOUSE.ROTATE: - if ( event.ctrlKey || event.metaKey || event.shiftKey ) { + if ( event.ctrlKey || event.metaKey || event.shiftKey ) { - if ( scope.enablePan === false ) return; + if ( scope.enablePan === false ) return; - handleMouseDownPan( event ); + handleMouseDownPan( event ); - state = STATE.PAN; + state = STATE.PAN; - } else { + } else { - if ( scope.enableRotate === false ) return; + if ( scope.enableRotate === false ) return; - handleMouseDownRotate( event ); + handleMouseDownRotate( event ); - state = STATE.ROTATE; + state = STATE.ROTATE; - } + } - break; + break; - case THREE.MOUSE.PAN: + case THREE.MOUSE.PAN: - if ( event.ctrlKey || event.metaKey || event.shiftKey ) { + if ( event.ctrlKey || event.metaKey || event.shiftKey ) { - if ( scope.enableRotate === false ) return; + if ( scope.enableRotate === false ) return; - handleMouseDownRotate( event ); + handleMouseDownRotate( event ); - state = STATE.ROTATE; + state = STATE.ROTATE; - } else { + } else { - if ( scope.enablePan === false ) return; + if ( scope.enablePan === false ) return; - handleMouseDownPan( event ); + handleMouseDownPan( event ); - state = STATE.PAN; + state = STATE.PAN; - } + } - break; + break; - default: + default: - state = STATE.NONE; + state = STATE.NONE; - } + } - break; + break; - case 1: + case 1: - switch ( scope.mouseButtons.MIDDLE ) { + switch ( scope.mouseButtons.MIDDLE ) { - case THREE.MOUSE.DOLLY: + case THREE.MOUSE.DOLLY: - if ( scope.enableZoom === false ) return; + if ( scope.enableZoom === false ) return; - handleMouseDownDolly( event ); + handleMouseDownDolly( event ); - state = STATE.DOLLY; + state = STATE.DOLLY; - break; + break; - default: + default: - state = STATE.NONE; + state = STATE.NONE; - } + } - break; + break; - case 2: + case 2: - switch ( scope.mouseButtons.RIGHT ) { + switch ( scope.mouseButtons.RIGHT ) { - case THREE.MOUSE.ROTATE: + case THREE.MOUSE.ROTATE: - if ( scope.enableRotate === false ) return; + if ( scope.enableRotate === false ) return; - handleMouseDownRotate( event ); + handleMouseDownRotate( event ); - state = STATE.ROTATE; + state = STATE.ROTATE; - break; + break; - case THREE.MOUSE.PAN: + case THREE.MOUSE.PAN: - if ( scope.enablePan === false ) return; + if ( scope.enablePan === false ) return; - handleMouseDownPan( event ); + handleMouseDownPan( event ); - state = STATE.PAN; + state = STATE.PAN; - break; + break; - default: + default: - state = STATE.NONE; + state = STATE.NONE; - } + } - break; + break; - } + } - if ( state !== STATE.NONE ) { + if ( state !== STATE.NONE ) { - document.addEventListener( 'mousemove', onMouseMove, false ); - document.addEventListener( 'mouseup', onMouseUp, false ); + document.addEventListener( 'mousemove', onMouseMove, false ); + document.addEventListener( 'mouseup', onMouseUp, false ); - scope.dispatchEvent( startEvent ); + scope.dispatchEvent( startEvent ); - } + } - } + } - function onMouseMove( event ) { + function onMouseMove( event ) { - if ( scope.enabled === false ) return; + if ( scope.enabled === false ) return; - event.preventDefault(); + event.preventDefault(); - switch ( state ) { + switch ( state ) { - case STATE.ROTATE: + case STATE.ROTATE: - if ( scope.enableRotate === false ) return; + if ( scope.enableRotate === false ) return; - handleMouseMoveRotate( event ); + handleMouseMoveRotate( event ); - break; + break; - case STATE.DOLLY: + case STATE.DOLLY: - if ( scope.enableZoom === false ) return; + if ( scope.enableZoom === false ) return; - handleMouseMoveDolly( event ); + handleMouseMoveDolly( event ); - break; + break; - case STATE.PAN: + case STATE.PAN: - if ( scope.enablePan === false ) return; + if ( scope.enablePan === false ) return; - handleMouseMovePan( event ); + handleMouseMovePan( event ); - break; + break; - } + } - } + } - function onMouseUp( event ) { + function onMouseUp( event ) { - if ( scope.enabled === false ) return; + if ( scope.enabled === false ) return; - handleMouseUp( event ); + handleMouseUp( event ); - document.removeEventListener( 'mousemove', onMouseMove, false ); - document.removeEventListener( 'mouseup', onMouseUp, false ); + document.removeEventListener( 'mousemove', onMouseMove, false ); + document.removeEventListener( 'mouseup', onMouseUp, false ); - scope.dispatchEvent( endEvent ); + scope.dispatchEvent( endEvent ); - state = STATE.NONE; + state = STATE.NONE; - } + } - function onMouseWheel( event ) { + function onMouseWheel( event ) { - if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return; + if ( scope.enabled === false || scope.enableZoom === false || ( state !== STATE.NONE && state !== STATE.ROTATE ) ) return; - event.preventDefault(); - event.stopPropagation(); + event.preventDefault(); + event.stopPropagation(); - scope.dispatchEvent( startEvent ); + scope.dispatchEvent( startEvent ); - handleMouseWheel( event ); + handleMouseWheel( event ); - scope.dispatchEvent( endEvent ); + scope.dispatchEvent( endEvent ); - } + } - function onKeyDown( event ) { + function onKeyDown( event ) { - if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return; + if ( scope.enabled === false || scope.enableKeys === false || scope.enablePan === false ) return; - handleKeyDown( event ); + handleKeyDown( event ); - } + } - function onTouchStart( event ) { + function onTouchStart( event ) { - if ( scope.enabled === false ) return; + if ( scope.enabled === false ) return; - event.preventDefault(); + event.preventDefault(); - switch ( event.touches.length ) { + switch ( event.touches.length ) { - case 1: + case 1: - switch ( scope.touches.ONE ) { + switch ( scope.touches.ONE ) { - case THREE.TOUCH.ROTATE: + case THREE.TOUCH.ROTATE: - if ( scope.enableRotate === false ) return; + if ( scope.enableRotate === false ) return; - handleTouchStartRotate( event ); + handleTouchStartRotate( event ); - state = STATE.TOUCH_ROTATE; + state = STATE.TOUCH_ROTATE; - break; + break; - case THREE.TOUCH.PAN: + case THREE.TOUCH.PAN: - if ( scope.enablePan === false ) return; + if ( scope.enablePan === false ) return; - handleTouchStartPan( event ); + handleTouchStartPan( event ); - state = STATE.TOUCH_PAN; + state = STATE.TOUCH_PAN; - break; + break; - default: + default: - state = STATE.NONE; + state = STATE.NONE; - } + } - break; + break; - case 2: + case 2: - switch ( scope.touches.TWO ) { + switch ( scope.touches.TWO ) { - case THREE.TOUCH.DOLLY_PAN: + case THREE.TOUCH.DOLLY_PAN: - if ( scope.enableZoom === false && scope.enablePan === false ) return; + if ( scope.enableZoom === false && scope.enablePan === false ) return; - handleTouchStartDollyPan( event ); + handleTouchStartDollyPan( event ); - state = STATE.TOUCH_DOLLY_PAN; + state = STATE.TOUCH_DOLLY_PAN; - break; + break; - case THREE.TOUCH.DOLLY_ROTATE: + case THREE.TOUCH.DOLLY_ROTATE: - if ( scope.enableZoom === false && scope.enableRotate === false ) return; + if ( scope.enableZoom === false && scope.enableRotate === false ) return; - handleTouchStartDollyRotate( event ); + handleTouchStartDollyRotate( event ); - state = STATE.TOUCH_DOLLY_ROTATE; + state = STATE.TOUCH_DOLLY_ROTATE; - break; + break; - default: + default: - state = STATE.NONE; + state = STATE.NONE; - } + } - break; + break; - default: + default: - state = STATE.NONE; + state = STATE.NONE; - } + } - if ( state !== STATE.NONE ) { + if ( state !== STATE.NONE ) { - scope.dispatchEvent( startEvent ); + scope.dispatchEvent( startEvent ); - } + } - } + } - function onTouchMove( event ) { + function onTouchMove( event ) { - if ( scope.enabled === false ) return; + if ( scope.enabled === false ) return; - event.preventDefault(); - event.stopPropagation(); + event.preventDefault(); + event.stopPropagation(); - switch ( state ) { + switch ( state ) { - case STATE.TOUCH_ROTATE: + case STATE.TOUCH_ROTATE: - if ( scope.enableRotate === false ) return; + if ( scope.enableRotate === false ) return; - handleTouchMoveRotate( event ); + handleTouchMoveRotate( event ); - scope.update(); + scope.update(); - break; + break; - case STATE.TOUCH_PAN: + case STATE.TOUCH_PAN: - if ( scope.enablePan === false ) return; + if ( scope.enablePan === false ) return; - handleTouchMovePan( event ); + handleTouchMovePan( event ); - scope.update(); + scope.update(); - break; + break; - case STATE.TOUCH_DOLLY_PAN: + case STATE.TOUCH_DOLLY_PAN: - if ( scope.enableZoom === false && scope.enablePan === false ) return; + if ( scope.enableZoom === false && scope.enablePan === false ) return; - handleTouchMoveDollyPan( event ); + handleTouchMoveDollyPan( event ); - scope.update(); + scope.update(); - break; + break; - case STATE.TOUCH_DOLLY_ROTATE: + case STATE.TOUCH_DOLLY_ROTATE: - if ( scope.enableZoom === false && scope.enableRotate === false ) return; + if ( scope.enableZoom === false && scope.enableRotate === false ) return; - handleTouchMoveDollyRotate( event ); + handleTouchMoveDollyRotate( event ); - scope.update(); + scope.update(); - break; + break; - default: + default: - state = STATE.NONE; + state = STATE.NONE; - } + } - } + } - function onTouchEnd( event ) { + function onTouchEnd( event ) { - if ( scope.enabled === false ) return; + if ( scope.enabled === false ) return; - handleTouchEnd( event ); + handleTouchEnd( event ); - scope.dispatchEvent( endEvent ); + scope.dispatchEvent( endEvent ); - state = STATE.NONE; + state = STATE.NONE; - } + } - function onContextMenu( event ) { + function onContextMenu( event ) { - if ( scope.enabled === false ) return; + if ( scope.enabled === false ) return; - event.preventDefault(); + event.preventDefault(); - } + } - // + // - scope.domElement.addEventListener( 'contextmenu', onContextMenu, false ); + scope.domElement.addEventListener( 'contextmenu', onContextMenu, false ); - scope.domElement.addEventListener( 'mousedown', onMouseDown, false ); - scope.domElement.addEventListener( 'wheel', onMouseWheel, false ); + scope.domElement.addEventListener( 'mousedown', onMouseDown, false ); + scope.domElement.addEventListener( 'wheel', onMouseWheel, false ); - scope.domElement.addEventListener( 'touchstart', onTouchStart, false ); - scope.domElement.addEventListener( 'touchend', onTouchEnd, false ); - scope.domElement.addEventListener( 'touchmove', onTouchMove, false ); + scope.domElement.addEventListener( 'touchstart', onTouchStart, false ); + scope.domElement.addEventListener( 'touchend', onTouchEnd, false ); + scope.domElement.addEventListener( 'touchmove', onTouchMove, false ); - scope.domElement.addEventListener( 'keydown', onKeyDown, false ); + scope.domElement.addEventListener( 'keydown', onKeyDown, false ); - // make sure element can receive keys. + // make sure element can receive keys. - if ( scope.domElement.tabIndex === - 1 ) { + if ( scope.domElement.tabIndex === - 1 ) { - scope.domElement.tabIndex = 0; + scope.domElement.tabIndex = 0; - } + } - // force an update at start + // force an update at start - this.update(); + this.update(); }; @@ -1193,13 +1193,13 @@ THREE.OrbitControls.prototype.constructor = THREE.OrbitControls; THREE.MapControls = function ( object, domElement ) { - THREE.OrbitControls.call( this, object, domElement ); + THREE.OrbitControls.call( this, object, domElement ); - this.mouseButtons.LEFT = THREE.MOUSE.PAN; - this.mouseButtons.RIGHT = THREE.MOUSE.ROTATE; + this.mouseButtons.LEFT = THREE.MOUSE.PAN; + this.mouseButtons.RIGHT = THREE.MOUSE.ROTATE; - this.touches.ONE = THREE.TOUCH.PAN; - this.touches.TWO = THREE.TOUCH.DOLLY_ROTATE; + this.touches.ONE = THREE.TOUCH.PAN; + this.touches.TWO = THREE.TOUCH.DOLLY_ROTATE; }; diff --git a/src/pug/templates/docs-gcode.pug b/src/pug/templates/docs-gcode.pug index 298d6ee..34170c9 100644 --- a/src/pug/templates/docs-gcode.pug +++ b/src/pug/templates/docs-gcode.pug @@ -26,8 +26,8 @@ //-///////////////////////////////////////////////////////////////////////////// script#docs-gcode-template(type="text/x-template") - // Modified from http://linuxcnc.org/docs/html/gcode.html - - var base = 'http://linuxcnc.org/docs/html/gcode'; + // Modified from https://linuxcnc.org/docs/html/gcode.html + - var base = 'https://linuxcnc.org/docs/html/gcode'; - var camotics_base = 'https://camotics.org/gcode.html'; .cheat-sheet @@ -582,16 +582,16 @@ script#docs-gcode-template(type="text/x-template") p | The Buildbotics controller implements a subset of LinuxCNC GCode. | Supported commands are listed above. You can find further help with - | #[a(href="http://wikipedia.com/wiki/G-code", target="_blank") GCode] + | #[a(href="https://wikipedia.com/wiki/G-code", target="_blank") GCode] | programming on the LinuxCNC website: ul - li: a(href="http://linuxcnc.org/docs/html/gcode/overview.html", + li: a(href="https://linuxcnc.org/docs/html/gcode/overview.html", target="_blank") | G Code overview - li: a(href="http://linuxcnc.org/docs/html/gcode/g-code.html", + li: a(href="https://linuxcnc.org/docs/html/gcode/g-code.html", target="_blank") | G Code reference - li: a(href="http://linuxcnc.org/docs/html/gcode/m-code.html", + li: a(href="https://linuxcnc.org/docs/html/gcode/m-code.html", target="_blank") | M Code reference diff --git a/src/pug/templates/docs-help.pug b/src/pug/templates/docs-help.pug index 30871a2..a2e4503 100644 --- a/src/pug/templates/docs-help.pug +++ b/src/pug/templates/docs-help.pug @@ -32,7 +32,7 @@ script#docs-help-template(type="text/x-template") p | You can find a detailed user manual at | - a(href="http://buildbotics.com/manual-v1-0", target="_blank") + a(href="https://buildbotics.com/manual-v1-0", target="_blank") | buildbotics.com/manual-v1-0 |. @@ -41,30 +41,30 @@ script#docs-help-template(type="text/x-template") | If you're having trouble or just want to chat with other Buildbotics | CNC controller owners, head over to the Buildbotics forum at | - a(href="http://forum.buildbotics.com", target="_blank") + a(href="https://forum.buildbotics.com", target="_blank") | forum.buildbotics.com |. Register on the site and post a message. We'll be happy to help. h2 CAD/CAM Software p - a(href="http://wikipedia.com/wiki/Computer-aided_manufacturing", + a(href="https://wikipedia.com/wiki/Computer-aided_manufacturing", target="_blank") CAM | | software can be used to create GCode | automatically from | - a(href="http://wikipedia.com/wiki/Computer-aided_design", + a(href="https://wikipedia.com/wiki/Computer-aided_design", target="_blank") CAD | | models. Here are a few CAD/CAM resources: ul - li: a(href="http://camotics.org/", target="_blank") + li: a(href="https://camotics.org/", target="_blank") | CAMotics - Open-Source CNC Simulator - li: a(href="http://librecad.org/", target="_blank") + li: a(href="https://librecad.org/", target="_blank") | LibreCAD - Open-Source 2D CAD li: a(href="https://www.freecadweb.org/", target="_blank") | FreeCAD - Open-Source 3D CAD - li: a(href="http://www.openscad.org/", target="_blank") + li: a(href="https://www.openscad.org/", target="_blank") | OpenSCAD - Open-Source 3D CAD for programmers - li: a(href="http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Cam", + li: a(href="https://wiki.linuxcnc.org/cgi-bin/wiki.pl?Cam", target="_blank") LinuxCNC CAM resources diff --git a/src/py/bbctrl/v4l2.py b/src/py/bbctrl/v4l2.py index 22fbfaf..fd46334 100644 --- a/src/py/bbctrl/v4l2.py +++ b/src/py/bbctrl/v4l2.py @@ -191,12 +191,12 @@ v4l2_field = enum def V4L2_FIELD_HAS_TOP(field): return ( - field == V4L2_FIELD_TOP or - field == V4L2_FIELD_INTERLACED or - field == V4L2_FIELD_INTERLACED_TB or - field == V4L2_FIELD_INTERLACED_BT or - field == V4L2_FIELD_SEQ_TB or - field == V4L2_FIELD_SEQ_BT) + field == V4L2_FIELD_TOP or + field == V4L2_FIELD_INTERLACED or + field == V4L2_FIELD_INTERLACED_TB or + field == V4L2_FIELD_INTERLACED_BT or + field == V4L2_FIELD_SEQ_TB or + field == V4L2_FIELD_SEQ_BT) def V4L2_FIELD_HAS_BOTTOM(field): @@ -405,7 +405,7 @@ V4L2_PIX_FMT_NV21 = v4l2_fourcc('N', 'V', '2', '1') V4L2_PIX_FMT_NV16 = v4l2_fourcc('N', 'V', '1', '6') V4L2_PIX_FMT_NV61 = v4l2_fourcc('N', 'V', '6', '1') -# Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm +# Bayer formats - see https://www.siliconimaging.com/RGB%20Bayer.htm V4L2_PIX_FMT_SBGGR8 = v4l2_fourcc('B', 'A', '8', '1') V4L2_PIX_FMT_SGBRG8 = v4l2_fourcc('G', 'B', 'R', 'G') V4L2_PIX_FMT_SGRBG8 = v4l2_fourcc('G', 'R', 'B', 'G') -- 2.27.0